Different behavior between graph explorer and calling the API directly

Copper Contributor

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
Maybe the problems you are having are just because the list access from the Graph is still in beta
Then why is it working in graph explorer, which usr the same exact api, with the same credentials?

It is difficult to help without seeing the code you are running...

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('{...",
"value": []
}

 

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

- 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.

It can't get any stupider than that. Your first question did it. I assigned all the permissions I needed (delegated) in Azure Portal, to my app, including the one you mention. However I didn't press "grant". So they were not really effectives I guess. Still doesn't understand why I had some but not others. But now it works. I get the items.

 

Thanks for pointing me out to the obvious :) Looks like I needed it to resolve my "issue".

Excellent. Glad it is working now.