Forum Discussion
YoChao
May 17, 2023Copper Contributor
Confirming API permissions and SharePoint endpoint URL for accessing SharePoint data through an API.
Hello All,
I have been working on a project that requires accessing SharePoint data using APIs.
I have referred to the official documentation provided by Microsoft, specifically the guide on "Complete basic operations using SharePoint REST endpoints" available at the following link:
According to the documentation, I have registered an application on the Azure portal. However, the guide does not mention which API permissions need to be added to the application in order to retrieve SharePoint data. Therefore, I have added the following API permissions (please note that I am not certain if these permissions are correct):
I use these API permissions to get OAuth token, and I can verify the inclusion of my API permissions within the response's scope.
However, I have encountered an issue when attempting to access the SharePoint endpoint using the obtained token. The error message I receive is as follows:
In addition, I also tried replacing the endpoint URL for SharePoint.
(The provided endpoint URLs for SharePoint in the following official documents are all different, which has caused me a lot of confusion about the exact SharePoint endpoint URL:
Microsoft Official Documentation | SharePoint Endpoint URL |
https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245826(v=office.15)?redirectedfrom=MSDN | http://<sitecollection>/<site>/_api/web/lists(listid) |
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/sharepoint-net-server-csom-jsom-and-rest-api-index | http://<site url>/web/lists(guid'<list id>') |
https://learn.microsoft.com/en-us/answers/questions/607425/how-do-i-get-access-token-for-sharepoint-online-re | https://{site_url}/_api/web/lists/GetByTitle('List Title') |
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-rest-endpoints | http://<site url>/_api/web/lists |
I believe this kind of situation should not occur in Microsoft's official documentation, and there should be a comprehensive RESTful API Swagger available for developers to refer to.
It's really frustrating that all four official documents have different SharePoint endpoint URLs......
Finally, I would like to request clarification on the following two points, which I believe are crucial for meeting my requirements:
1. What are the API permissions that need to be configured in the application?
2. What is the exact SharePoint endpoint URL that should be used?
I appreciate any guidance and support you can provide to help me address these issues.
Thank you for your attention to this matter.
No RepliesBe the first to reply