Skip to main content
Nintex Community Menu Bar

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 :

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

 

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 :

//*elocal-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) :

 

 

I hope that this will help the community !

 

Caroline Jung

Sorry I haven't read the last version of your post .

Have you tried to get and then upload the file content using this web request:

http://site url/_api/web/lists/getbytitle('list title')/items(item id)
/AttachmentFiles('file name')/$value

Thank you for the quick response, Caroline. I think I am getting close with the documents you have sent me, but I am really new to REST (I hadn’t even heard of it before last Friday). How do I “translate” this into the Web Request action of a Nintex workflow? How do I get “content-length”?


Actually this web request works without "content-length" header.

Do you use Nintex for O365 or for SharePoint?


We are using Nintex for SharePoint.

I used the links you sent to retrieve the attachment using the /$value, and saved it to a string variable. When I tried to do the POST Web request using that variable and the /$value, it gave me an error that the Uri string is too long. When I retrieve the attachment, should I be saving it to a string variable or doing something else with it when it is returned?

I can’t tell you how much I appreciate you helping me with this. Thank you!


If you get an error regarding a too long url, then you need to increase the maxUrlLength attribute of httpRuntime element in the web.config of the SharePoint web application executing your workflow (if the workflow is scheduled it's the

OWSTIMER.EXE.config instead of the web.config): https://msdn.microsoft.com/en-us/library/e1f13641(v=vs.100).aspx.

The string variable should be ok to store the attachment content.

Hope this helps


Hey,

Thanks a lot for this post.

Any idea to call a API with a OAuth authentication ?

Thanks,

Damien


Hi Damien,

Here's a link to a blog that can help you on that:

https://community.nintex.com/community/build-your-own/nintex-for-office-365/blog/2017/02/09/working-with-security-credentials-requestdigest-fedauth-rtfa?et=notification.mention

Hope this helps


Caroline, I have read this thread with great interest.  I've have been trying to get the "accept-language" header value in workflow using the Web Call action with no success.  We need to use the result to set the language for labels on task forms and notifications.  I must be missing something simple.  My response contains no reference to the "accept-language" header.

Any suggestions?

-Ken


Hi Ken,

It seems that SharePoint REST API calls don't return any accept-language header.

What do you want to do exactly? Maybe we can find a workaround...


Thanks Caroline, but we decided to scrap the function involved.

Regards,

Ken


Hi Caroline,

Thank you for the nice blog. I have followed all the steps to update a document in library. The REST API call to fetch the item  was excuted without any error. But I don't see that column s are updated. No error in the logs as well.

The body looks like as follows. None of the column is updated.

 '__metadata' : { 'type' : '{WorkflowVariable:ListName}'},
     'Textcolumn' : 'Complete',
'choicecolumn' : 'No',
'Date Column' : '{Common:CurrentDate}'
}

Any help?


Hi Rashmi,

Can you share the url that you're using to perform the request?


Hi Caroline,

I am looking for help to understand the chekcout, update and checkin REST API calls for a document in the document library.

1. I want to know how do we overide the checkout. I am using a site collection workflow. Does the just checkout REST API call will override the checkout?

2. I am checking out the document and updating the metadata using update REST API and checkin using REST API.

But I don't see the meta data is getting updated.

If I use only UPDATE REST API without any checkout and checkin, it works - metadata gets updated

Any idea about this behavior. What should I be doing to update the metadata along with checkout and checkin. I should be able to update the document from the workflow even if it is already checked out.

Thanks

Rashmi


Hi Rashmi,

Unfortunately, I haven't worked so far with check-in and check-out REST API calls.

I'm afraid I can't help you a lot with that.

Did you finally get a solution?


Hi Caroline,

I was able to resolve the check out and check in requirements using REST API calls. Here is the example for the REST API URL,

Checkout -

{WorkflowVariable:WebURL}/_api/web/GetFileByServerRelativeUrl('/sites/WorkflowVariable:ServerRealtiveURLofPage}')/CheckOut()

Update Item by REST API

Checkin - {WorkflowVariable:WebURL}/_api/web/GetFileByServerRelativeUrl'/sites/WorkflowVariable:ServerRealtiveURLofPage}')/CheckIn(checkintype=1)


Great

Thanks for sharing this !


Hi Caroline,

I'm getting an issue during GET operation stating : Workflow Status

Error performing web request. The underlying connection was closed: An unexpected error occurred on a send.

Below is the screen shot of the configuration which I did to achieve the same.

Please let me know what I'm doing wrong here.

Regards,

Akram


Hi Akram,

I think that this error is related to server/network configuration. If you try to execute this request directly from the SharePoint server, I think that you will get the same error.

Does the SharePoint farm have multiple front servers? If yes, is there a load balancer?

The better way to solve this issue is to check with an administrator in the event viewer of the SharePoint server if there are more details.

Hope this helps,

Caroline


Hi Caroline,  I am working on a web request to the REST API that will update a Hyperlink Column.  I went through all of the steps that both you and Tomasz laid out SAML Request, Response Message, but there's no BinaryRequestToken element in the response.  

SAML RESPONSE

SAML RESPONSE

So I tried grabbing the innerXML from the X509SKI element instead.  Sent that in and get the Response Headers back.  The I log them all out to find the Cookie Header (which accoring to Tomaz is Index Item #6) and it's not there. Is this solution still valid?

 

Thanks,

Mario


Hi Mario,

I'm afraid I can't help with that but I'm sure that ‌ can


What env. are you working in? I see a SPO term in your screenshots, so possibly this is O365

This is not a BinaryRequestToken, but BinarySecurityToken:

Try to post your SAML Request Security Token using Postman for example, to see the response. I just did it and I've been received that token.

Also using Postman you will have the possibility to preview, whether this way of authentication is even allowed - I have access to three tenants, on two of them this is disallowed. Possibly because of some policy settings or MFA.

Regards,

Tomasz


Thanks Tomasz,

The client has a dedicated Office 365 tenant and they indeed have MFA enabled. Thanks for the reply I will pass this along.

Mario


Hi Caroline,

I need your help please. I wanted to update the datefield, but its throwing some error

{
"__metadata": { "type": getItemTypeForListName(listName) },
"Title": "firsdt",

"ApplicatinDate" : "{ItemProperty:ApplicationDate}"

}

i tried converting iso format and assign it, but in vein

{
"__metadata": { "type": getItemTypeForListName(listName) },
"Title": "firsdt",

"ApplicatinDate" : "{WorkflowVariable:ISOConvertedDate}"

}

getting below error

Error performing web request. <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-1, Microsoft.SharePoint.Client.InvalidClientQueryException</m:code><m:message xml:lang="en-US">I

Pelase suggest to me how to save date field and person or group


Url i am using is : 

Web URL/_api/web/lists/getbytitle('txtListName')/items

I am able to save other fields except date and person group


Hi Vijay,

Can you send me the complete error message? In the workflow, you can send you an email with the error message in the body and set the body to be in plain text instead of rich text.

To update a date column, the json should look like this :

'StartDate':'2014-01-29T08:00:00Z'

Can you send me the value of the variable "ISOConvertedDate"?


Reply