Here in this SharePoint designer tutorial, we will discuss how we can call REST API in SharePoint Designer Workflow using Call HTTP Web Service SharePoint 2013 designer workflow action. We have developed the workflow using SharePoint designer 2013.
Call Rest API from a SharePoint 2013 designer workflow
Create a custom list, “IT,” and let’s say that we want to create a Workflow which returns the first one by using REST API, which is based on Dept. Filter, which shows Title Name.
In the screenshot given below, we need to look back at the XML generated in the Browser. Looking at the JSON output given below from our .getJSON() call, we find the values to show and highlight/copy XML name as we’ll need the exact value since jQuery is case sensitive.
https://serversitename/_api/web/lists/getbytitle('IT')/items?$filter=Dept eq 'RnD'
You should get something, as shown below.
Since the $json option is not supported in SharePoint 2013 REST API, to get the response in a JSON format, you will have to update the Accept and Content-Type HTTP headers of your Rest HTTP call to be more specific.
- Accept: application/json;odata=verbose
- Content-Type: application/json;odata=verbose
Now, let’s get back to our Workflow in SharePoint Designer 2013.
We need to create the Request header and this is possible by using a Dictionary ->.
In the existing stage, type Build -> rename the variable dictionary as RequestHeader.
Click this and click Build your dictionary; add the Accept and the Content-Type headers.
Go to Action ->Core Action->Call HTTP Web Service option. Now, let’s focus on the Http request by adding a Call action.
Click this and paste your http request.
Choose the Advanced Properties icon. In the Call HTTP Web Service Parameters dialog, click RequestHeaders dropdown, choose RequestHeader variable and click OK.
In the Call action, click Response and associate the response to a new variable: JSonResult (of type Dictionary) and a new variable: ShowTitle(of type String).
After the Call action, add a new Get action.
Add a log activity and display the ShowTitle variable in the log.
The final stage should look as shown below. Publish and run the Workflow.
In the Workflow history, you should find Filter Title, which is shown below.
You may like following SharePoint workflow tutorials:
- SharePoint Approved and Rejected buttons not appearing in task form in Visual Studio 2015 workflow
- SharePoint Hosted Add-in: Send Email using visual studio workflow
- Activate Workflows can use app permissions Feature programmatically using C#.Net .net managed object model code
- How to Trigger Sharepoint 2013 Designer workflow on a list item by calling REST API using jQuery?
- Deploy SharePoint 2013 designer workflow into production in SharePoint online
- SharePoint Online Create Workflow History List using PowerShell or using SharePoint Designer 2013
Hope this SharePoint 2013 tutorial explains, how to call Rest API from a SharePoint 2013 designer workflow.
Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.