What is the checklist for calling the Sharepoint API to access a file?

Jon A 0 Reputation points
2024-03-21T15:54:57.54+00:00

Good day,

I have a question regarding the Sharepoint API. I would like to access an Excel file in SharePoint, using a PostMan. What are the checklist of things I need to ensure?

  1. Make sure there is a registered app. I need the tenant, client id, and secret value to make requests.
  2. Make sure the app has the appropriate permissions. I need Microsoft Graph (File.Read.All, User.Read) and SharePoint (Site.Read.All)
  3. Make sure the file is in the correct folder. I can copy the full path from SharePoint and it will look like this.
       https://mysite.sharepoint.com/sites/mysite/folder1/folder2/filename.txt
       
    
  4. Now I can finally login, save the access token, and then use that to download the file from SharePoint. Follow the examples here

Am I missing some steps? I tried this and it still says 401 Unauthorized, so I think I forgot something.

Thank you for your time.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,685 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 35,466 Reputation points Microsoft Vendor
    2024-03-22T03:09:40.91+00:00

    Hi @Jon A,

    The azure ad app is for Graph api access sharepoint data. If you are using SharePoint rest api, I would recommend you to use Sharepoint app only to access sharepoint. Please refer to the following steps

    https://anoopt.medium.com/accessing-sharepoint-data-using-postman-sharepoint-rest-api-76b70630bcbf

    If you want to use azure ad app, I would recommend you to use graph api like following article

    https://www.merge.dev/blog/sharepoint-rest-api-postman-get-files


    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.