Forum Discussion

Etienne Fortin's avatar
Etienne Fortin
Copper Contributor
May 10, 2017

Different behavior between graph explorer and calling the API directly

I'm learning on the Graph API as a whole and to access Sharepoint in particular. I figured out how to authenticate with the help of the ADAL library for Python. I can access my sharpeoint site. I can get a list of all the lists of the site. But somehow when I ask for the items in a list, I get nothing. In Graph Explorer, I get each lines.

 

Any idea what might be wrong? I don't understand how I can access the site and get to the list without any problem, but the items does not show up. I also have no error. I only get a "value" : [] answer, will the usuall context stuff.

 

Any help is appreciated.

 

ETienne Fortin

 

7 Replies

    • Etienne Fortin's avatar
      Etienne Fortin
      Copper Contributor

      I authenticate with ADAL and get a token. Then I create a header like this:

       

      headers = {
      'User-Agent' : 'SharepointBridge/1.0',
      'Authorization' : 'Bearer %s' % (tk),
      'Accept' : 'application/json',
      'Content-Type' : 'application/json'
      }

       

      Where tk contains my token.

       

      My request to Graph is done like that:

       

      r = requests.get('https://graph.microsoft.com/beta/sites/XXXXXXX.sharepoint.com,XXXXXX,XXXXXXX/lists/{list_id}/items',  headers = headers)

       

      I can query anything below "items". But /items returns:

       

      {
      "@odata.context": "https://graph.microsoft.com/beta/$metadata#sites('XXXXXXXsharepoint.com%2CXXXXXX%2CXXXXXX')/lists('{list_id}')/items",
      "value": []
      }

       

      If I do the exact same query in Graph Explorer, I get my list with all the information, not an empty value.

      • paulschaeflein's avatar
        paulschaeflein
        MVP
        - Are you sure that your application requested and received consent for Sites.Read.All?
        - Is it a large list, and perhaps being throttled?
        - Try using Postman to issue the call with your app id/token.
    • Etienne Fortin's avatar
      Etienne Fortin
      Copper Contributor
      Then why is it working in graph explorer, which usr the same exact api, with the same credentials?

Resources