Azure

Add Recordsdata to SharePoint On-line Library utilizing POSTMAN

Introduction

Usually, we have to test if the generated Service Principal is utilizing Azure AD App registration. A service principal may be outlined as a secured identification that’s used towards an authorization endpoint, and on success, the authorization endpoint generates an Entry Token, which has a restricted lifetime, and utilizing this entry token, the applying can carry out required operations towards the secured useful resource in Azure. The thought is to remove the utilization of passwords to authenticate to the secured useful resource in Azure and have the applying have superb grained and programmatic entry to the useful resource secured by Azure. On this article, we’re utilizing the idea of OAuth2.0 Consumer Credentials Grant movement to acquire the Entry Token. Extra concerning the OAUTH and repair principals may be discovered within the references part.

Pre-requisites

  • An Azure AD the App registered first utilizing the Microsoft Entra App Registration course of
  • Acquire Consumer ID, and Consumer Secret of the Azure AD App.
  • Configure the app to have write entry to the SharePoint website.

Add Recordsdata to SharePoint On-line Library utilizing POSTMAN

Step 1. As soon as the Postman instrument is opened, on the left-hand facet, create a group by clicking on + button and title it ‘Graph API Check’. This step is non-compulsory, as it will create a group of requests that we may check with for future reference.

Upload Files to SharePoint Online Library using POSTMAN

Step 2. Add new request. Within the fast launch, click on on hyperlink ‘Add a request’.

Upload Files to SharePoint Online Library using POSTMAN

Step 3. Replace the request to ‘Get Web site ID’, as this request is to get website ID utilizing the graph API.

https://graph.microsoft.com/v1.0/websites/{TenantName}.sharepoint.com:/websites/{SiteName}

On this case, the URL is  

https://graph.microsoft.com/v1.0/websites/gmfinancial.sharepoint.com:/groups/Dept-BusinessIntelligence

Enter the URL and ensure the request is of kind ‘GET’.

Upload Files to SharePoint Online Library using POSTMAN

Step 4. Click on on the Authorization tab, Choose the kind ‘OAuth2.0’.

Upload Files to SharePoint Online Library using POSTMAN

On scrolling down, you need to see a bit on the best facet known as ‘Configure New Token’. Enter the next particulars

Token Identify: It may be something to your reference. I’m coming into it as ‘Check Entry Token’.

Grant Kind: Consumer Credentials, since we’re utilizing shopper ID and shopper Secret to get entry token.

Entry Token URL: it’s within the format https://login.microsoftonline.com/{TENANTID}/oauth2/v2.0/token. Substitute the Tenant ID along with your group Tenant.

https://login.microsoftonline.com/e45cbcc1-1760-419a-a16b-35802285b3b3/oauth2/v2.0/token

Consumer ID: The shopper ID worth whereas creating the Azure AD App Registration.

Consumer Secret: The shopper secret worth. As talked about in reference article, Creating Azure AD app, when organising shopper secret, the key will solely seem as soon as through the preliminary setup and is required to avoid wasting the key worth on the very first time.

Scope: Enter the scope worth as  https://graph.microsoft.com/.default

Consumer Authentication: Depart it as default which is ‘Ship as Fundamental Auth header’

Upload Files to SharePoint Online Library using POSTMAN

Step 5. On scrolling down additional, on the very finish you need to see the button known as ‘Get New Entry Token’. It’s best to see the under choice window that claims ‘Authentication Full’.

Upload Files to SharePoint Online Library using POSTMAN

Instantly there’s one other window that exhibits the output of Entry Token that received generated. Click on on the button ‘Use Token’.

Upload Files to SharePoint Online Library using POSTMAN

 

Step 6. Now click on on ‘Ship’. On success you need to see the message like under in a JSON format and the id column comprises the Web site Id worth which is second string. Copy the Web site ID. This will likely be used to retrieve the lists and libraries. On this case the location ID is d9305f2d-bf54-4e16-ab0a-eafea6ddbe39.

Step 7. Now enumerate the libraries for the location. Within the fast launch click on on ‘Graph API Check’ tree choices (…) and click on on ‘Add request’ and title the request as ‘Get Libraries.

Upload Files to SharePoint Online Library using POSTMAN

To get the all of the libraries inside the website, you have to use the under graph API request.

https://graph.microsoft.com/v1.0/websites/{SITEID}/Drives

https://graph.microsoft.com/v1.0/websites/d9305f2d-bf54-4e16-ab0a-eafea6ddbe39/Drives

Upload Files to SharePoint Online Library using POSTMAN

Upload Files to SharePoint Online Library using POSTMAN

Within the ‘Authorization’ reuse the identical entry token that received generated on the earlier request. Choose the kind as ‘OAuth2.0’ and token ‘Check Entry Token’. Please word that the life time of the entry token is 60 to 90 minutes.

Be certain the request is Get after which click on on ship

Upload Files to SharePoint Online Library using POSTMAN

Step 8. On profitable authentication, you need to see all of the doc libraries and their properties in JSON format similar to under. On this case word the ID of the doc library that you simply need to check towards. I’m deciding on ‘DemoDocs’ and the ID. On this case the ID I received from JSON response is b!LV8w2VS_Fk6rCur-pt2-OVDFDL8q3dtDh8JGmVbe8XKP33vrBqB4RYVSiQScfpDc

Upload Files to SharePoint Online Library using POSTMAN

Step 9. To view the contents of the library, the Graph api request format is

https://graph.microsoft.com/v1.0/Drives/{DriveID}/root:/{LIBRARYNAME}:/Kids

Create New request, and title it as ‘Enumerate Library’. For view the recordsdata for explicit library on this case ‘Demo Docs’ the URL needs to be within the following format

https://graph.microsoft.com/v1.0/Drives/b!LV8w2VS_Fk6rCur-pt2-OVDFDL8q3dtDh8JGmVbe8XKP33vrBqB4RYVSiQScfpDc/root:/DemoDocs:/Kids

Step 10. In the same means reuse the identical entry token and click on on ‘Ship’.

Step 11. On profitable authentication, you need to the content material of the library within the JSON format.

Upload Files to SharePoint Online Library using POSTMAN

Step 12. Create New request, and title it as ‘Add file’. For importing the file to explicit library, the URL needs to be within the following format.

https://graph.microsoft.com/v1.0/drives/{LIBRARYID}/root:/{FILENAME}:/content material

Upload Files to SharePoint Online Library using POSTMAN

Upload Files to SharePoint Online Library using POSTMAN

Step 13. Be certain the kind of request is ‘PUT’ and enter the under URL

https://graph.microsoft.com/v1.0/drives/b!LV8w2VS_Fk6rCur-pt2-OVDFDL8q3dtDh8JGmVbe8XKP33vrBqB4RYVSiQScfpDc/root:/SampleContract3.docx:/content material

Choose the ‘Physique’ after which choose ‘binary’ after which choose a file from the native folders.

Upload Files to SharePoint Online Library using POSTMAN

Step 14. Be certain to reuse authentication token from the earlier steps. Click on on Authorization kind choose the kind is ‘OAuth 2.0’. Click on on ‘Ship’.

On profitable authentication, you need to see the message with the file title in JSON format.

Upload Files to SharePoint Online Library using POSTMAN

You also needs to see the file title within the SharePoint doc library.

Upload Files to SharePoint Online Library using POSTMAN

Problem: Beneath are the potential subject that you could possibly get,

Upload Files to SharePoint Online Library using POSTMAN

This might be as a consequence of Authentication is expired. On this case, regenerate a brand new entry token and you ought to be good. To generate new entry token go to authorization tab, and in the best facet you need to see all of your earlier values beneath the choice ‘Configure New token’ is populated. Scroll down and click on on ‘New Entry Token’. The identical course of is  defined in Step #4.

Graph API Calls

For reference, under are the graph API calls in a desk.

Request Description Request Kind Graph API Finish Level
To get Web site ID GET https://graph.microsoft.com/v1.0/websites/{TenantName}.sharepoint.com:/websites/{SiteName}
To get Entry Token GET https://login.microsoftonline.com/{TENANTID}/oauth2/v2.0/token
To outline scope NA https://graph.microsoft.com/.default
To get Libraries for a website GET https://graph.microsoft.com/v1.0/websites/{SITEID}/Drives
To get Doc library recordsdata GET https://graph.microsoft.com/v1.0/Drives/{DriveID}/root:/{LIBRARYNAME}:/Kids
To add file to a library PUT https://graph.microsoft.com/v1.0/drives/{LIBRARYID}/root:/{FILENAME}:/content material

Conclusion

Thus, on this article we’ve seen the way to use POSTMAN instrument to check the Azure AD App permissions and scope utilizing the Graph API finish level.

References

Know extra about our firm at Skrots. Know extra about our providers at Skrots Companies, Additionally checkout all different blogs at Weblog at Skrots

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button