What permissions are needed to use SharePoint REST API?

Sesha 0 Reputation points
2024-02-27T12:36:47.1766667+00:00

Hello. I'm attempting to use the SharePoint REST API v1, but I keep receiving "Access denied" errors despite adding the necessary permissions. Could you please inform me of any additional permissions that might be required for me to proceed with this task?

Permissions -> SharePoint - Sites.Selected - Read and Write Access to the SharePoint site

These are the endpoints I'm working with:

  1. GET https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles
  2. GET https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles('{file_name}')/$value

To generate the access token, I am using the endpoint https://login.microsoftonline.com/{Tenant}/oauth2/v2.0/token with

User's image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,890 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,599 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,949 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Mohamed BEN AMOR 5 Reputation points
    2024-02-27T13:25:28.65+00:00

    Hello,

    You have to create an application in EntralD and give it the right permissions (Sites.Selected). For the scope, try using the following when you create the application:

    https://graph.microsoft.com/.default
    
    1 person found this answer helpful.
    0 comments No comments

  2. RaytheonXie_MSFT 35,071 Reputation points Microsoft Vendor
    2024-02-28T03:12:15.25+00:00

    Hi @Sesha,

    You could refer to following steps to check if you have grant access to the token correctly. https://techcommunity.microsoft.com/t5/microsoft-sharepoint-blog/develop-applications-that-use-sites-selected-permissions-for-spo/ba-p/3790476

    ---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.


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.