I have created several lists in SharePoint Online within a subsite each of which have a number of rows of data and I am now trying to access this list and it's row data (items) via the Graph API.
I have managed to successfully access the List information in 2 different ways;
- GET https://graph.microsoft.com/beta/sites/{root}:/{path}:/lists/{list-name}
- GET https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-name}
However now when I try to use either of those ways to get the underlying items;
- GET https://graph.microsoft.com/beta/sites/{root}:/{path}:/lists/{list-name}/items
- GET https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-name}/items
NOTE: I've also tried expanding the fields (E.g. /items?$expand=fields) but with no luck.
it just returns response with an empty value array e.g.
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#sites('{site-id}/lists('{list-name}')/items)",
"value": []
}
I am using Service Auth mechanism outlined here: https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service and I the following permission setup;
- User.Read.All
- Group.Read.All
- Directory.Read.All
- Sites.ReadWrite.All
I decided to try to access the data with the same queries using the Online Graph explorer with my credentials and the data returned without a problem so I would assume it is something to do with accessing via the authentication mechanism above.
UPDATE
The more I investigate this the more it appears to relate to Site/List permissions. I removed my access permissions on one of the lists and it returned the same response as above (e.g. empty values array) whereas previous it worked. I really cannot understand how you would provide Site/List permissions for a userless app (e.g. following this route: https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service).
Any advice or pointers on what possibly could be causing the problem would be greatly appreciated.
Thanks, John