SharePoint Pals
 | Sign In
Using Nintex Workflow with SharePoint Rest Api
by Senthil Kumaresan 24 Sep 2015
Author
SharePoint Architect
Visits   
Today  :   6     Total  :    6484

Nintex workflows have powerful utilities that help to perform some of the tedious operations like batch updating content or configuration. One such action is the “Web Request”.

I had a scenario where I would need to disable content approval feature from some of the libraries in a set of sites that reside in site collections on different web applications. There are different approaches to do this. First is to write a PowerShell script. But writing a script is pretty easy but executing will take time as I had an environment where the SharePoint Farm is managed by a dedicated server team and I will have to wait to run the script on a change window. Second is to write a .Net Client Side Managed Code program to iterate across all the sites in site collection that reside in different web application which needs extensive coding to.

But there was even easier approach to use Nintex workflows for batch operations which I luckily had in my organization’s SharePoint On-Premises environment. With the introduction of Rest in SharePoint 2013, it is easier now to perform CRUD operations on SharePoint objects using the “Web Request” action in Nintex Workflows.

I had the list of SharePoint Site Url’s in a SharePoint List where I would need my workflow program to iterate through all the sites and remove content approval feature from a library on the site.

There are 2 categories of Http Methods to use in the web request action.

1. Get – Read operation to resources which the user defined in the web request action has rights to.

2. Post – Create, Update and Delete operations on resources which the user defined in the web request action has rights to.

a. For Update operation, A header X-HTTP-Method has to be set with value of MERGE

b. For Delete operation, A header X-HTTP-Method has to be set with value of DELETE

c. All Post operation requires a request digest token to validate post backs to SharePoint.

For my example, since I want to disable content approval for libraries in a set of sites, I would need to perform an update operation using the Post Http Method. I have designed the workflow so that it performs a “for each” loop action to iterate through list of sites and calls the rest service for each site and performs the update operation.

First, to perform a Post method you will need a request digest token.

To get a request digest token you will have a perform a post operation to the Rest Url https://<Site Url>/_api/ContextInfo and store the response in a variable

clip_image001

Use Query XML action to query the Digest token value from the Response xml and store it in a variable which is required for the Post operation.

clip_image003

After getting the digest token, I can now call the Post method to perform the update operation on the list properties to disable the content approval on the list using the web request action.

clip_image004

Note, I have modified the content type to “application/json;odata=verbose” since I am sending a Json request in the body of the web request.

Since this is an update operation, I have added 3 headers

1. X-HTTP_Method : MERGE

2. X-RequestDigest : <Digest token got earlier in a variable>

3. IF-MATCH : *

The IF-MATCH: * header is used to overwrite any changes that has already been changed on the server.

The body contains the Json input to perform the merge operation. For all SharePoint Rest API related info check msdn link

So it is pretty simple to perform any Batch CRUD operations using Nintex Workflows, Instead of writing a script.

blog comments powered by Disqus

SharePoint Pals

Pals
SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile

Training

Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community




SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to articles@sharepointpals.com in a word document.

Related Resources

Recent Tweets

Twitter January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart https://t.co/VxSi4QnNrC

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window https://t.co/EQ7HkoZDkX

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features https://t.co/zAXObHCFpH

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013 https://t.co/LEwnUoI7EY

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services https://t.co/Yvp2VPFIRP

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation