coco
coco

Reputation: 21

How can I fix SharePoint Resr API access error?

I'm trying to get data with SharePoint REST API but stucking with "System.UnauthorizedAccessException" error. How can I fix this?

What I did is...

  1. I got access token.

POST https://login.microsoftonline.com/{{tenantName}}/oauth2/v2.0/token

  1. I tried to get sharepoint list items with the access token I got.

GET https://{{xxx.sharepoint.com}}/sites/{{sitename}}/_api/web/lists/GetByTitle('CSV')/items

  1. With the 2nd command, I got error message like below.

    "odata.error": { "code": "-2147024891, System.UnauthorizedAccessException", "message": { "lang": "en-US", "value": "Access denied. You do not have permission to perform this action or access this resource." }

Upvotes: 2

Views: 1101

Answers (1)

Amos
Amos

Reputation: 2091

Check whether the site you requested matches the scope set by app permission xml.It is possible that the scope does not match and the requested site fails to authenticate the request.

Upvotes: 0

Related Questions