Home > Software engineering >  Microsoft Graph API Filter SharePoint List Items By CreatedBy User
Microsoft Graph API Filter SharePoint List Items By CreatedBy User

Time:12-27

I am using Microsoft Graph API and trying to filter items in a SharePoint List by CreatedBy User but am not sure how to write the filter query.

https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$$filter=

I have tried "https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?&$filter=AuthorLookupId eq {user-id}" but it doesn't seem to work.

CodePudding user response:

According to my research and testing, unfortunately, there is currently no Graph API can filter items by CreatedBy User. As a workaround, I recommend you use the following REST API to filter items:

https://xxxxx.sharepoint.com/sites/xxx/_api/web/lists/getbytitle('xxxx')/items?$filter=AuthorId eq 21

Thanks for your understanding.

CodePudding user response:

You can at least filter items by field AuthorLookupId. The filtering can be allowed by adding the header Prefer: HonorNonIndexedQueriesWarningMayFailRandomly.

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields&filter=fields/AuthorLookupId eq '10'

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields&filter=fields/Title eq 'whatever'
  • Related