Share via


Testing SharePoint 2016 or 2013 or SharePoint Online REST API using Postman

Introduction

Hi techies. Today we’ll discuss how to test and perform basic operations in REST APIs for SharePoint using a powerful and user-friendly tool POSTMAN. This will work for SharePoint 2016/2013 or SharePoint Online sites.

Approach

Testing Rest API using Postman. Primarily, we need to get it installed from link below

https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en

Once installed, it can be added to the Chrome Launcher which is great for easy access. Once you have it installed we can launch it and should be presented with the following:

http://www.enjoysharepoint.com/pc/sharepoint-online-rest-api-calls-using-postman-tool.png

SharePoint 2013 adds the ability for you to remotely interact with SharePoint sites by using REST. Now, you can interact directly with SharePoint objects by using any technology that supports standard REST capabilities.

To access SharePoint resources using REST, construct a RESTful HTTP request, using the Open Data Protocol (OData) standard, which corresponds to the desired client object model API. For example:

We can perform below operation in Postman.

GET- Use GET to retrieve data from SharePoint like the list, list items, etc.

POST - Use POST to create entities such as lists and sites. The SharePoint 2013 REST service supports sending POST commands that include object definitions to endpoints that represent collections. For POST operations, any properties that are not required are set to their default values. If you attempt to set a read-only property as part of a POST operation, the service returns an exception.

PUT- Use PUT and MERGE operations to update existing SharePoint objects.
Any service endpoint that represents an object property set operation supports both PUT requests and MERGE requests.
For MERGE requests, setting properties is optional; any properties that you do not explicitly set retain their current property.

For PUT requests, if you do not specify all required properties in object updates, the REST service returns an exception. In addition, any optional properties you do not explicitly set are set to their default properties

DELETE- Use the HTTP DELETE command against the specific endpoint URL to delete the SharePoint object represented by that endpoint. In the case of recyclable objects, such as lists, files, and list items, this results in a Recycle operation

http://www.enjoysharepoint.com/pc/sharepoint-online-rest-api-calls-using-postman-tool-1.png

Get the site Title
https://onlysharepoint2013.sharepoint.com/sites/Bhawana/\_api/web/title

http://www.enjoysharepoint.com/pc/sharepoint-online-rest-api-calls-using-postman-tool-2.png

Get particular list data:
https://onlysharepoint2013.sharepoint.com/sites/Bhawana/\_api/lists/getbytitle('Bhawana_Practice')/items
 

http://www.enjoysharepoint.com/pc/sharepoint-online-rest-api-calls-using-postman-tool-3.png

Get all the Lists:
https://onlysharepoint2013.sharepoint.com/sites/Bhawana/\_api/lists

http://www.enjoysharepoint.com/pc/sharepoint-online-rest-api-calls-using-postman-tool-4.png

Create a SharePoint LIST using below JSON
{
  '_metadata':{'type':SP.List},
  'AllowContentTypes': true,
  'BaseTemplate': 104,
  'ContentTypesEnabled': true,
  'Description': 'My list description',
  'Title': 'RestTest'
}

http://www.enjoysharepoint.com/pc/sharepoint-online-rest-api-calls-using-postman-tool-5.png

References:

- Testing SharePoint 2016 or 2013 or SharePoint Online REST API using Postman

Conclusion:

Here we have discussed how we can test SharePoint 2016 or 2013 or SharePoint Online REST API using Postman.

Other Languages

The article is available in other languages:
Testowanie SharePointa 2016/2013/Online REST API za pomocą Postman (pl-PL)