cju@evolusys.ch

How to execute a SP2013 REST API request with Nintex Workflow

Blog Post created by cju@evolusys.ch Champion on Apr 24, 2015

How to execute a SP2013 REST API request with Nintex Workflow

With all the Nintex Workflow actions, we can achieve lots of great workflows. Sometimes, we'd like to build more complicated, technical, reusable workflows. For these workflows, we need more actions and possibilities that can be achieved by calling SharePoint ASMX web services or SP2013 REST API requests.

As the ASMX web services are deprecated in SharePoint 2013 and SharePoint Online, it is recommended to use SP2013 REST API instead when it is possible (not all functionalities of the ASMX web services are available in SP2013 REST API).

I'd like to help you building your SP2013 REST API requests.

There are two categories of SP2013 REST API requests :

  • POST : to update, create or remove information in SharePoint,
  • GET : to retrieve information from SharePoint.

The process to execute these two types of requests is different.

 

How to execute a GET request

 

To execute a GET request, a "Web request" action only is needed. The configuration of the action should look like this :

 

REST_API_Request_GET.png

 

It is possible to select a text variable in the "Store result in" field to get the response of the request and then use a "Query XML" action to extract the information needed.

 

 

How to execute a POST request

 

The execution of a POST request is more complex. A request digest is first needed in order to pass the security information to the server when sending the POST request.

To get the request digest, the following "Web request" action should be executed :

 

REST_API_Request_Digest.png

 

A text variable has to be selected in the "Store result in" field.

Then the request digest has to be extracted from the response of the request.

To extract this information, a "Query XML" action has to be configured to execute the following XPath query :

//*[local-name()='FormDigestValue']

 

QueryXML_extract_request_digest.png

 

Once the request digest is stored in a variable, it is possible to execute the POST request via a "Web request" configured like the following :

 

REST_API_Request_POST.png

 

 

 

Example : How to update a list item using REST API

 

Before executing the POST request used to update a list item, the request digest and the list item entity type full name are needed.

To get the request digest, follow the steps explained above.

To get the list item entity type full name, execute the following "Web request" action (where "txtListName" is the title of the list where the list item to update is) :

 

rest_api_get_listitementitytypefullname.png

 

The next step is to extract the list item entity type full name from the response of the above request using the following XPath query :

//*[local-name()='ListItemEntityTypeFullName']

 

The last step is to execute the POST request with the following "Web request" action (where "numID" is the id of the item to update) :

 

rest_api_update_item.png

 

 

I hope that this will help the community !

 

Caroline Jung

Outcomes