0

Unable to use Microsoft Graph API to create or update SharePoint list items with client credentials access token (getting access token with out a user), I get the following error,

Error when calling either POST or PATCH

I'm able to successfully call GET and DELETE methods with the same access tokens for the same site/list, additionally I'm able to call all methods GET/POST/PATCH/DELETE for the same site/list using the user generated access token.

For my use case I need to able to create/update list items with out user access so, followed this article - https://learn.microsoft.com/en-us/graph/auth-v2-service, API has required permissions granted in the application

API permissions

can't seem to find any documentation on what exactly I'm missing, looks like POST/PATCH endpoints are looking for some user info in the token, but client crendentials do not have any user info so not sure what to do next, Here's the documentation I'm following https://learn.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=http & I've tried using the .net graph client SDK as well and I get the same error message for both POST/PATCH requests.

same error with .net graph sdk

Any help on how to successfully create/update sharepoint list items via graph api using client credential token would be highly appreciated.

Followed this article in setting up the application in azure ad - https://learn.microsoft.com/en-us/graph/auth-v2-service, Added app roles are as highlited in this article https://learn.microsoft.com/en-us/answers/questions/756563/app-roles-in-client-credentials-scope-in-azure-b2c.html but no luck.

  • Hava you see these two posts: https://stackoverflow.com/questions/51450929/one-of-the-provided-arguments-is-not-acceptable-creating-folder-using-microsoft and https://stackoverflow.com/questions/65141447/patch-update-on-sharepoint-one-of-the-provided-arguments-is-not-acceptable? They deleted the app registration and registered it again to fix the issue. You can also get the error when trying to set a field to an invalid value: https://stackoverflow.com/questions/39767770/one-of-the-provided-arguments-is-not-acceptable-when-sending-a-sharing-invitat. – Marc Dec 04 '22 at 10:26
  • Could you share the code how do you create listitem and send it via SDK? – user2250152 Dec 05 '22 at 12:14

1 Answers1

0

Hope you are not using delegated permission in your personal account , enter image description here

Looks like there is something wrong with your API call ,make sure you are using the correct API call - https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items

You can also Try to create and Update in graph explorer- https://learn.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=http#example .

Hope this helps

Thanks

vicky kumar
  • 563
  • 3
  • 11