How to upload a file via Graph API To a SharePoint

 Graph API is a powerful tool that allows developers to interact with various Microsoft services, including SharePoint. With Graph API, it's easy to upload files to a SharePoint site. Today, I would like to share my knowledge on how to upload a file to a SharePoint site using Graph API via Postman. Postman is a popular tool for testing and managing APIs, developers can easily test the Graph API's file upload functionality and ensure that the system is working as expected.

The process of uploading a file to SharePoint via Graph API involves sending a request to the SharePoint Graph API endpoint. Before sending a request to the SharePoint Graph API endpoint, the developer must authenticate and authorize the request using Microsoft's authentication mechanism based on OAuth 2.0 protocol. This involves obtaining an access token that allows the developer to access the required SharePoint site.

Overall, the combination of Graph API, SharePoint, and Postman can be a powerful tool for businesses looking to streamline their document management processes and improve collaboration among team members.

1. Registering your App in Azure Portal

  • Search and select App Registration.

No alt text provided for this image

  • Name for your App and Click Register.

No alt text provided for this image

  • The system will exhibit the following screen.

No alt text provided for this image

  • Add Redirect URI

No alt text provided for this image
No alt text provided for this image

  • Add Redirect URIS as shown below.

No alt text provided for this image

  • Select Certificate & secrets from left hand Menu and then click New client Secret as shown below.

No alt text provided for this image

  • Enter the Description and select Expire duration, then click on Add.

No alt text provided for this image

  • Now we shall add permissions to the App.

Select API permissions from left hand side navigation menu and then select graph API.

No alt text provided for this image

  • You should select the Application Permission and select Site.ReadWrite.All and click add permission.

No alt text provided for this image

  • In my Case I should request the permission from Admin, if you’re the admin then you can grant permission by clicking Grant Admin Content.

No alt text provided for this image
No alt text provided for this image

2. Uploading a file Via Postman.

  • In this Step We are generating the access token via Postman this can be use between 60 to 90 minutes. We have one header “Content-Type” and for the body we have four parameters.

No alt text provided for this image

No alt text provided for this image
No alt text provided for this image

  • In the Response message you can find the ID with comma separated strings , there you should get the Second string which is highlighted above.


  • In this Step we will find out how to get the List ID’s. we should use get method with bearer Token and following Graph API https://graph.microsoft.com/v1.0/sites/{{SiteID}}/lists

No alt text provided for this image

  • In this Step we will find out how to Get the Drive ID. This is a folder path in your SharePoint. To achieve this We should use get method with bear Token and the following Graph API

https://graph.microsoft.com/v1.0/sites/{{SiteID}} /Drives.

No alt text provided for this image
No alt text provided for this image

  • Now we are going to list the items what is exist in the folder path to do that we should use the following API Call https://graph.microsoft.com/v1.0/Drives/{{DriveID}}/root:/ERP-CRM Enhancement (ERP Dev):/Children.

No alt text provided for this image
No alt text provided for this image

  • Now we can upload a File. In this step we should use Put Method with Bearer Token and following API.

https://graph.microsoft.com/v1.0/drives/{{DriveID}}/root:/ERP-CRM Enhancement (ERP Dev)/BC.png:/content.

No alt text provided for this image
No alt text provided for this image

  • Select a file and click send.

No alt text provided for this image

  • We can see the file what I have uploaded.

No alt text provided for this image

Hope you find it useful.

Thank you.

Comments