Using Call HTTP Web Service In SPD Workflow And Using App Step

Using Call HTTP web service in SPD workflow and using App step:

First we will learn when to use App step – one of the reasons that App step is used  is to provide elevated permissions in the workflow.

Example

We want to use HTTP web service and get items from root site collection in a workflow created on a sub site or we want communication across site collection using workflow.

Scenario 1

Getting items from a list at root site collection through a workflow created at a sub site.

Source of the List – http://<siteurl>/sites/sitename 

Sub site where workflow is create - http://<siteurl>/sites/sitename/subsitename

Step 1 – Configure App step

Go to site settings of sub site as shown below.

To allow workflow to use app permissions

Click the Settings icon as shown in the figure.

Figure Opening the Site Settings page

1. Go to Site Settings.

2. In the Site Actions section, select Manage site features.

3. Locate the feature called Workflows which can use app permissions, as shown in the figure, and then click Activate.

Note

This feature will not activate unless you have properly configured the SharePoint Workflow platform and also apps for SharePoint.

Figure The site feature, 'Workflows can use app permissions'

 

1. Click the Settings icon as shown in the figure.

Figure: Opening the Site Settings page

1. Go to Site Settings.

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

3. Copy the client section of the App Identifier. This is the identifier between the last "|" and the "@" sign, as shown in the figure.

4. Now navigate to the app page to grant permission to app.

http://<siteurl>/sites/sitename/_layouts/15/appinv.aspx - This is the URL of site collection where list exists which we will access through call http web service.

App Id – It is the workflow app Id of sub site from where our workflow will access SharePoint list at root site collection.

Paste the App Id in the text box and click Lookup, It will get Title, App Domain and Redirect URL – it is the URL of the sub site whose workflow App step will access list at root site collection through Call HTTP web service.

Permission Request XML 

Paste this as is in Permission Request XML field, do not change anything, it is not configurable.

“<AppPermissionRequests>

<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />

</AppPermissionRequests>”

1. Click Create.

2. You will then be asked to trust the Workflow app, as shown in the figure. Click Trust It.

 

Use App step in workflow

1. Open SharePoint designer

2. Second step is to Get Form digest value.

3. Build a dictionary and add dictionary item.

4. Name – Content-Type, Value - application/json;odata=verbose

6. Add another dictionary item

7. Name – Accept, Value - application/json;odata=verbose

9. Add App step.

10. Add Call HTTP Web Service Action and paste the site URL as shown below – This is the URL to get context info which in turn will give Form digest value. Form Digest value is needed as we are trying to access a list from a sub site.

12. Add header to Call HTTP Web Service action

14. Select Call Web Service Action and click Advance Properties and add header as a request header

16. Get Form Digest value from dictionary d/GetContextWebInformation/FormDigestValue and store the value in a variable.

17. We will access SharePoint list in next stage

18. Build a dictionary and add X-RequestDigest apart from Accept and Content-Type.

20. In X-RequestDigest add form digest variable value.

21. Add another App step and add Call HTTP web service action.

 

23. Use Rest services URL to get data from list - [%Workflow Context:Current Site URL%]/_api/web/lists/GetByTitle('Village%20Directory')/items(‘ItemId’)?$select=FacilityName

Scenario 2

Getting items from a list across site collection through a workflow created at another site collection.

Suppose we have two site collections with URL’s

Site1 URL - http://<siteurl>/sites/sitename1

Site2 URL - http://<siteurl>/sites/sitename2

We want to access data from site1 through a workflow created at site2

Then we need to add get App Id from site1 as shown below

And we should grant app permission on site2 with following URL

http://<siteurl>/sites/site2/_layouts/15/appinv.aspx

Follow the same steps as explained above.

Ebook Download
View all
Learn
View all