How To Get All The Lists Using HTTP Web Service In SharePoint Designer 2013 Workflow

Introduction

In SharePoint 2013 Workflows, you call a Web Service using a new action, which was introduced in SharePoint 2013 named Call HTTP Web Service. This action is flexible and allows you to make the simple calls to a Web Service easily, or, if needed, you can create more complex calls, using HTTP verbs as well as allowing you to add HTTP headers.

The Call HTTP Web Service action lets you specify any of the several request methods, including GET, PUT, POST and DELETE. This lets you tell the Web Services, specifically RESTful services what is to be done on the service that you’ve specified with the URL property on the activity. For more details, please refer to this link.

In this article, you will be creating a Site Workflow and log the entire list names in the Workflow history list.

Endpoint URI

To get all the lists from SharePoint site endpoint, URL will be http://sitename/_api/web/lists

HTTP Request

GET – Read a Resource.

Workflow Design

Workflow will be designed with the stages (Retrieve Lists and Process Lists), as shown below:

stages

stages

Create Site Workflow

  1. Open SharePoint Site in Designer 2013.
  2. In the top navigation bar, click Site Workflow.

    Site Workflow

  3. Enter the Name and Description. Select Platform Type and click OK button.

Create Workflow Local Variables

  1. In the top navigation bar, click Local Variables and create the following variables:

    variables

    variables

    variables

Stage 1- Retrieve Lists

Stage

  1. Set Workflow Variable Action – Set the workflow variable varStrURL to http://sitename/_api/web/lists.

    varStrURL

  2. Build Dictionary Action – Add the dictionary items, given below. Set the varDicRequestHeaders variable.

    Add

    Add

    Add

  3. Call HTTP Web Service Action – Set the variable, as shown below. Right click Call HTTP Web Service action and click Properties. Set RequestHeaders parameter to varDicRequestHeaders variable.

    Call HTTP

    Call HTTP

    Call HTTP

  4. Transition to stage – Go to next stage Process Lists.

Stage 2- Process Lists

Stage

  1. Get an Item from a Dictionary Action.

    Get

  2. Count the items in a Dictionary Action.

    Get

  3. Log to History List Action.

    Action
    Action

  4. Set the Workflow Variable Action.

    Action

  5. Add loop up to n times and add the actions, as shown below:.

    Action

    Action

  6. Transition to stage – Go to End of Workflow.

Publish the workflow

In the top navigation bar, click Publish. The workflow will be published successfully.

Test the workflow

  1. Navigate to the site.
  2. Click Settings and subsequently click Site Contents.
  3. Click Site Workflows.

    workflow

  4. Click Get SharePoint Lists Workflow.

    workflow
  5. Once the Workflow is completed, click Completed link.
    link

  6. You will be able to see the Workflow history, as shown below:

    history

Summary

Thus, in this article, you have seen,how to get all the lists using HTTP Web Service in SharePoint Designer 2013 Workflow.