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.
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
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.
,
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
- Click the settings icon and then click site settings, as shown below:
- In the Site Actions section, click Manage Site Features, as shown below:
- Activate the feature – Workflows can use app permissions.
Grant full permissions to Workflow
- Click the Settings icon and subsequently, click Site Settings.
- In the Users and Permissions section, click Site app permissions.
- Copy the highlighted client section of the app identifier.
- Navigate to the Grant permission to an app page, https://sitename/_layouts/15/appinv.aspx.
- Paste the client Id in the app Id and then click Lookup. Title, App Domain and Redirect URL will be automatically populated.
- Paste the following XML to Permission Request XML section to grant full permissions.
- <AppPermissionRequests>
- <AppPermissionRequest Scope="http://sitename" Right="FullControl" />
- </AppPermissionRequests>
- Click Create button.
- Click Trust It button.
Create List Workflow
- Open SharePoint site in Designer 2013.
- In the top navigation bar, click List Workflow and subsequently click List Provisioning.
- Enter the Name and Description, select Platform Type and click OK button.
Create Workflow Local Variables
- In the top navigation bar, click Local Variables and create the following variables:
Stage- Create List
- App Step – Click app step. Inside the app step add all the other actions.
- Set Workflow Variable Action – Set the Workflow variable varStrURL to http://sitename/_api/web/lists,
- Log varStrURL variable value to the Workflow history list.
- Build Dictionary Action – Add the dictionary items, given below and set to varDicRequestHeaders dictionary variable.
- Log varDicRequestHeaders variable value to the Workflow history list.
- Build Dictionary Action – Add the dictionary items, given below and set to varDicMetadata dictionary variable.
- Log varDicMetadata variable value to the Workflow history list.
- Build Dictionary Action – Add the dictionary items given below and set to varDicParameters dictionary variable.
- Log varDicParameters variable value to the Workflow history list.
- 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.
- 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
- Navigate to the site.
- In the quick launch, click List Provisioning link.
- Click New Item.
- Click Save button.
- Select the newly created item, click Workflows in the ribbon interface.
- Click Create List Workflow link.
- Once the Workflow is completed, click completed link.
- You will be able to see the Workflow history, as shown below. A new list will be created successfully.
Summary
Thus, in this article, you have seen, how to create a list, using HTTP Web Service in SharePoint Designer 2013 Workflow.