Sitecore & Postman: A Quick Starter Guide


Working RESTful API for Sitecore ItemServices gets easier with Postman.

Prerequisites

  1. Download the latest version of Postman from here. I highly recommend Signing up to keep your Collections in sync.
  2. Enable SSL on the CMS environment. You can create a self signed certificate on the CMS environment and add an HTTPS binding
    Server Certificates.png
  3. Update Policy Setting in the App_Config/include/Sitecore.Services.client.config file to grant remote access to ItemService from Postman outside your CM server, by setting it to “Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy“. You can read more about this in Sitecore Documentation.
    Security Policy Settings
  4. For older versions of Postman, you may need to install Chrome Extension “Postman Interceptor” and enable Interceptor from Postman
    Postman Interceptor

 

Establishing Connection

The first step into establishing a connection is to Authenticate the REST API. For this, you can setup a new request in Postman as shown below:

Sitecore Postman Authentication

Here are the Request Details:

  • URL: https://{CM Server URL}/sitecore/api/ssc/auth/login
  • Method: POST
  • Header: Content-Type: application/json
  • Body:
    {
    “domain”:”sitecore”,
    “username”:”Type your username goes here”,
    “password”:”Type your password here”
    }

Please remember the following:

  • Ensure that the Authentication URL is HTTPS. However, once Authentication is successful, you can make requests using HTTP.
  • Ensure that the “Content-Type” is set to “Application/json” in the Request Header:Sitecore Postman Authentication Header
  • If the Authentication is successful, you will receive 200 response with a cookie “.ASPXAUTH”. This cookie will play a crucial role in performing additional authentication requests in Postman. Postman will take care of sending this cookie in the request header for subsequent request from the same domain.Sitecore Postman Authentication Cookie Response

Making your First Request

Request #1:
Retrieve Sitecore Item details by ID

Request Details:

  • URL: http://{CM Server URL}/sitecore/api/ssc/item/{Item ID goes here}?IncludeStandardTemplateFields
  • Method: GET
  • Header: Content-Type: application/json

Postman Retrieve Item by Id.png

Now you can proceed to perform additional Sitecore operations like Create/Edit/Delete items, fetch children items etc.


Request #2:
Retrieve Sitecore Item Children by ID

Request Details:

  • URL: http://{CM Server URL}/sitecore/api/ssc/item/{Item ID goes here}/children?IncludeStandardTemplateFields
  • Method: GET
  • Header: Content-Type: application/json

Request #3:
Edit Sitecore Item by ID

Request Details:

  • URL: http://{CM Server URL}/sitecore/api/ssc/item/{Item ID goes here}
  • Method: PATCH
  • Header: Content-Type: application/json
  • Body:
    {
    “__workflow state”:”guid of the workflow state item goes here”,
    “ItemName”:”Item name goes here”,
    “DisplayName”:”Display name goes here”
    }

Request #4:
Delete Sitecore Item by ID

Request Details:

  • URL: http://{CM Server URL}/sitecore/api/ssc/item/{Item ID goes here}
  • Method: DELETE
  • Header: Content-Type: application/json

Request #5:
Logout from REST API

Request Details:

  • URL: http://{CM Server URL}/sitecore/api/ssc/auth/logout
  • Method: POST
  • Header: Content-Type: application/json

Additional Documentation

Feel free to leave a reply here...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s