Calling Rest API from A SharePoint 2013 Designer Workflow

SharePoint online call rest api from workflow
InfoPath alternatives for form designing SharePoint

Here in this SharePoint desingner tutorial we will discuss how we can call REST API in SharePoint Designer Workflow. Whe have developed the workflow using SharePoint designer 2013.

Scenario:
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.

call rest api from sharepoint designer workflow
call rest api from sharepoint designer workflow

Objective:
Start SharePoint Designer 2013 and add a list Workflow on this IT list; make sure Workflow is a SharePoint 2013 Workflow.

SharePoint 2013 call rest api from designer workflow
SharePoint 2013 call rest api from designer workflow

Read some SharePoint 2013 tutorials:

In the screen shot 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.


SharePoint online call rest api from workflow
SharePoint online call rest api from workflow

Since the $json option is not supported in SharePoint 2013 REST API, to get the 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.

Steps-1:
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.

call rest api from workflow sharepoint 2013
call rest api from workflow sharepoint 2013

Steps-2:
Click this and click Build your dictionary; add the Accept and the Content-Type headers.

SharePoint 2016 call rest api from designer workflow
SharePoint 2016 call rest api from designer workflow

Steps-3:
Go to Action ->Core Action->Call HTTP Web Service option. Now, let’s focus on the Http request by adding a Call action.

Step-4:
Click this and paste your http request.

SharePoint online call rest api from designer workflow
SharePoint online call rest api from designer workflow

Steps-5:
Choose the Advanced Properties icon. In the Call HTTP Web Service Parameters dialog, click RequestHeaders dropdown, choose RequestHeader variable and click OK.


how to call rest api from sharepoint online designer workflow
how to call rest api from sharepoint online designer workflow

Step-6:
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.

how to call rest api from sharepoint 2013 designer workflow
how to call rest api from sharepoint 2013 designer workflow

Steps-7:
Add a log activity and display the ShowTitle variable in the log.

how to call rest api from sharepoint 2016 designer workflow
how to call rest api from sharepoint 2016 designer workflow

Steps-8:
The final stage should look as shown below. Publish and run the Workflow.

sharepoint workflow rest api call
sharepoint workflow rest api call

Steps-9:
In the Workflow history, you should find Filter Title, which is shown below.

sharepoint 2013 workflow rest api call
sharepoint 2013 workflow rest api call

Hope this will be helpful.

Similar SharePoint 2013 Tutorials


About Sagar Pardeshi

I am Developer working on Microsoft Technologies for the past 6+years. I am very much passionate about programming and my core skills are SharePoint, ASP.NET & C#,Jquery,Javascript,REST. I am running this blog to share my experience & learning with the community I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5,Sharepoint 2013 Core Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.

View all posts by Sagar Pardeshi →

Leave a Reply