Postman : Add item to SharePoint from postman using SharePoint REST api (Can be used to add/update items in SharePoint from external application through REST api)
Problem statement : Leverage Postman desktop or chrome extension to make SharePoint REST api calls to add/update items in SharePoint online site
There are many articles available in internet to make READ type calls from Postman . I am not going to detail out all the basic steps to configure the Postman , rather I will be focusing on the information required to make the ADD/UPDATE type of REST api calls.
Note: I am using Postman desktop application , but you can do the same through Postman Google chrome extension as well . Postman desktop client
Step-1 : Configure app permission in SharePoint Register add-in
Step-2 : Retrieve tenant ID
Step-3 : Retrieve access token
Step-4 : Connect SharePoint REST api to perform READ operations
For Step 1 through 4 , I suggest this article which consists of all the details
Additional reference article
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/authorization-and-authentication-of-sharepoint-add-ins
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-rest-endpoints
When you are confident that you are able to perform READ operations through Postman per above details , you are good to make next step to make Add/update operations , make below changes to ADD/UPDATE items in SharePoint list/libraries
App registration
While you register your app and provide permission level , make sure you are providing Write/Manage/FullControl types of access level , Refer to link App access level .
In my case I was trying to add a new item to SharePoint online list , I opted for below permission level , but you can provide minimum required permission as well
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/" Right="FullControl" />
</AppPermissionRequests>
Follow above process with new client ID and secret to record below items
- Tenant ID (Bearer realm)
- ResourceID
- Client ID
- Client Secret
- Form digest value
- ListItemEntityTypeFullName - This is different for each list/Library
- Accept - application/json;odata=verbose
- Authorization - Bearer "Access token value"
You should see a response as below , copy the value
Make SharePoint REST api call to add item to SharePoint Online list
Make REST api POST call to
https://SiteCollectionURL/_api/web/lists/GetByTitle('ThiloshList')/items
With below parameter in header
- Accept - application/json;odata=nometadata
- Authorization - Berer [access token]
- X-RequestDigest - [Form digest value previously copied]
- Content-Type - application/json;odata=verbose
In the Body , copy below JSON
- Authenticate the application
- Add the "test" item into "ThiloshList" SharePoint Online list
You can use same process to make any other ADD/Update SharePoint REST api calls.
No comments:
Post a Comment