How To Create A List Using HTTP Web Service In SharePoint Designer 2013 Workflow

In this article, you will learn how to create a list, using HTTP Web Service in SharePoint Designer 2013 Workflow.

Introduction

Call HTTP Web Service is a new action, introduced in SharePoint 2013 Designer Workflows. This action allows you to make 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 to do on the Service that you’ve specified with the URL property on the activity. For more details, please refer to the link.

In this article, I will be using the list, given below, to create and execute the Workflow.

home
Endpoint URI

To create a list in SharePoint site endpoint URL will be http://sitename/_api/web/lists.

HTTP Request

POST – To create entities such as lists and sites.

Workflow Design

Design

Forbidden or Unauthorized Issue

When you try to call HTTP Web Service to create list (HTTP POST), you will get the response code as forbidden or unauthorized as shown below. You will get the error, when you try to access the objects in SharePoint, that requires the elevated permissions.
,
Issue

By creating a Workflow with the elevated permissions you will be able to solve this issue. You will be performing the following steps:

  • Activate Workflows can use app permissions feature.
  • Grant full permissions to Workflow
  • Develop List Workflow and wrap all the actions inside an app step.

Reference: https://msdn.microsoft.com/en-us/library/office/jj822159.aspx

Activate Workflows can use app Permissions feature

  1. Click the settings icon and then click site settings, as shown below:
    Settings

  2. In the Site Actions section, click Manage Site Features, as shown below:
    Site Actions
  3. Activate the feature – Workflows can use app permissions.

    feature

Grant full permissions to Workflow

  1. Click the Settings icon and subsequently, click Site Settings.

    Settings

  2. In the Users and Permissions section, click Site app permissions.

    Settings

  3. Copy the highlighted client section of the app identifier.

    Identifier

  4. Navigate to the Grant permission to an app page, https://sitename/_layouts/15/appinv.aspx.

  5. Paste the client Id in the app Id and then click Lookup. Title, App Domain and Redirect URL will be automatically populated.
    app id
  6. Paste the following XML to Permission Request XML section to grant full permissions.

    Permission
    1. <AppPermissionRequests>  
    2.       <AppPermissionRequest Scope="http://sitename" Right="FullControl" />  
    3. </AppPermissionRequests>  
  7. Click Create button.
  8. Click Trust It button.
    Trust

Create List Workflow

  1. Open SharePoint site in Designer 2013.
  2. In the top navigation bar, click List Workflow and subsequently click List Provisioning.

    List 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:

    Local Variables

    Local Variables

Stage- Create List

Create

  1. App Step – Click app step. Inside the app step add all the other actions.

    App Step

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

    varStrURL

  3. Log varStrURL variable value to the Workflow history list.

    log

  4. Build Dictionary Action – Add the dictionary items, given below and set to varDicRequestHeaders dictionary variable.

    dictionary
    dictionary

    dictionary

    dictionary

  5. Log varDicRequestHeaders variable value to the Workflow history list.

    history

  6. Build Dictionary Action – Add the dictionary items, given below and set to varDicMetadata dictionary variable.

    dictionary
    dictionary

  7. Log varDicMetadata variable value to the Workflow history list.

    Log

  8. Build Dictionary Action – Add the dictionary items given below and set to varDicParameters dictionary variable.

    dictionary

    dictionary

    dictionary

    dictionary

    dictionary

    dictionary

  9. Log varDicParameters variable value to the Workflow history list.

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

    Call HTTP Web Service

    Call HTTP Web Service

  11. 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. In the quick launch, click List Provisioning link.
  3. Click New Item.
    New Item

  4. Click Save button.
  5. Select the newly created item, click Workflows in the ribbon interface.

    Workflows

  6. Click Create List Workflow link.

    Create
  7. Once the Workflow is completed, click completed link.

    Completed

  8. You will be able to see the Workflow history, as shown below. A new list will be created successfully.

    workflow history

Summary

Thus, in this article, you have seen, how to create a list, using HTTP Web Service in SharePoint Designer 2013 Workflow.