How to Call a REST API from SharePoint Designer Workflow?

Requirement: Call REST API in SharePoint designer workflow.

Using REST API in SharePoint Designer Workflow

SharePoint Designer workflow actions are very limited, and we can utilize REST API calls to extend them. Here is how to call a REST API method from SharePoint Designer workflow action: Call HTTP Web Service. In this article, let’s call a REST API method from the SharePoint Designer workflow to get the number of items from a SharePoint Online list.

Step 1: Create a New SharePoint 2013 Workflow

  • Create a new list workflow in SharePoint Designer. Make sure its Platform Type is set to “SharePoint 2013” in SharePoint api in sharepoint designer workflow

Create Necessary Workflow Variables:
Once the workflow is created, we need to create the necessary variables.

  • Click on the Local Variables button on the Ribbon >> Click on Add button >> Provide a name to the variable and set its type. Here is the list of variables I’ve created.
    Name Type
    requestHeader Dictionary
    responseContent Dictionary
    listItems Dictionary
    responseCode String
    count Integer

    Here is my workflow variables created:

Step 2: Build a Dictionary Object for Request Header

To start with, We need to set the value of requestHeader variable. We need this header dictionary object to get the response in JSON format as SharePoint REST APIs return XML.

  • Place the cursor under Stage 1, Click on Action >> Build Dictionary sharepoint designer workflow call rest api
  • Set the Output to Variable:requestHeader first and then Click on this link in the action >> Click on Add button >> Set the Name, Type and Value Parameters as below:
    Name Type Value
    accept String application/json;odata=verbose
    content-type String application/json;odata=verbose
  • Now, the requestHeader dictionary object should look like:

Step 3: Call HTTP Web Service

Next, we need to add Call HTTP Web Service action to call the REST method.

  • Click on Action >> Choose Call HTTP Web Service actionusing rest api in sharepoint designer workflow
  • Once the action is inserted, Select the Call HTTP Web Service action, Click on “Advanced” button from the toolbar.
  • Set the following parameters in the Advanced dialog box from the variables we’ve created.
  • Address: This is the REST API End-Point. We need to construct it according to our requirements. Click on the little three dots button to open String builder dialog. Click on Add or change lookup. Next dialog will be opened is Lookup for String. Select Data Source as Workflow Context and Field from source as Current site URL. E.g. Here I’ve constructed it as: “[%Workflow Context:Current Site URL%]_api/web/lists/getbytitle(‘[%Workflow Context:List Name%]’)/items” to retrieve all items from the current list.
    set REST API Address
  • RequestType: As we are retrieving data, this should be set as: HTTP GET
  • RequestHeaders: This is the headers of the REST call we will assign dictionary value that we created in the first step (requestHeader)
  • ResponseContent: This is a Dictionary variable we receive from the result from the REST call.
  • ResponseStatusCode: This is the status of REST call. We may need it to check the status of the call.

Step 4: Process the Response Received

Once we get the response from the REST API call, we need to traverse to d\results node to get list items data, as the API call returns result in below format (Thanks Fiddler!):

  • Insert Get an Item from a Dictionary action to extract results from JSON response. We need to traverse to  d/results node of the JSON responseContent.
  • Next, we need to Count Items in a Dictionary action to get the number of list items.
  • Then we use “Log to History List action to record the output we received.sharepoint designer 2013 workflow call rest api

Here is how the workflow looks like in SharePoint Designer
calling rest api from sharepoint designer workflow

  • Set Workflow Start Options: Click on “Workflow Settings” in the toolbar and set which action should trigger this workflow from “Start Options” section. E.g. Start workflow automatically when an item is created.
  • Save and Publish the workflow.

Here is the workflow in action:
call rest api in sharepoint designer workflow
In conclusion, Calling a REST API from a SharePoint Designer Workflow can greatly enhance the functionality and automation of your workflows. By following the steps outlined in this guide, you should now be able to create a new workflow in SharePoint Designer, add an action to make an HTTP call to a desired REST API endpoint, and use the returned data in the workflow.

Here is the Microsoft documentation of complete REST API methods:

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “How to Call a REST API from SharePoint Designer Workflow?

  • Great post, this help me alot. How you post data using POST method?


Leave a Reply

Your email address will not be published. Required fields are marked *