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 :
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 :
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 :
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 :
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) :
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 :
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) :
I hope that this will help the community !