MS Graph API not returning SPOL list values, but can return column fields? Permissions?

Zach P 0 Reputation points
2023-08-18T07:57:06.5533333+00:00

I have created an App Registration to allow extraction of SharePoint Online list items via the MS Graph API. I am using the App Registration client/secret ID to obtain a token, which is used as part of the authentication in the API calls.

I have the sites.selected permission applied to this App Registration which during testing seemed to be all that's required to return SharePoint Online list items (only from specific linked sites of course).

I can obtain all column/field names using the MS Graph API for a required site using the /columns endpoint. E.g. https://graph.microsoft.com/v1.0/sites/$(Site_ID_1)/lists/$(List_ID_1)/columns

So clearly my permissions allow for me to return that. But when I then try to extract the actual list items (i.e. the values in the list) using the /items end point there is nothing returned in [values:] json response.

https://graph.microsoft.com/v1.0/sites/$(Site_ID_1)/lists/$(List_ID_1)/items?expand=fields

or by specifying the column fields explicitly:

https://graph.microsoft.com/v1.0/sites/$(Site_ID_1)/lists/$(List_ID_1)/items?expand=fields*(select=@Value(name))

The response returned features an empty values[ ] response:

e.g:

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#sites('Site_ID_1')/lists('List_ID_1')/items","value":[]}

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-08-21T02:41:11.9233333+00:00

    Hi @Purver, Zach

    Here is a test for your reference:

    Please get the ID of the site first

    https://graph.microsoft.com/v1.0/sites/<hostname>.sharepoint.com:/sites/<sitename>

    Get id from response User's image

    Get list id from list setting:

    User's image

    Get list id from URLUser's image

    Here is result:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng


  2. Graph User 0 Reputation points
    2024-07-12T16:16:28.9366667+00:00

    SharePoint Get List Items

    SharePoint List column specifications

    https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{list/documentlibrary name or id}?expand=columns

    Retrieve all items and all field values

    https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{list/documentlibrary name or id}/items?expand=fields

    Retrieve specific SharePoint item using item Id and all field values

    https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{list/documentlibrary name or id}/items('Id')?expand=fields

    Retrieve specific SharePoint item using item Id and all field values

    https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{list/documentlibrary name or id}/items('Id')?expand=fields

    Retrieve SharePoint item(s) with select field values, replace ?expand=fields with these query parameters.

    ?expand=fields($select=field1, field2, field3)

    E.g.For selecting id and Title, use

    ?expand=fields($select=id,Title)

    Filter SharePoint item(s) using filter criteria

    ?expand=fields&$filter=fields/{fieldname} {operator} '{criteria}'

    Eg. For filtering data where Title = 'Hello World'

    ?expand=fields&$filter=fields/Title eq 'Hello World'

    Note:

    • Response will not return object/elements with null or empty
    • Use OData syntax for select filter and sort operations
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.