SharePoint 2013 : How to call OData Web Service End Point Using SharePoint Designer 2013 Workflows
In this article we are going to explore “Call HTTP Web Service” Workflow Action which is newly introduced in SharePoint 2013. In order to test this action will make use of OData Web Service End Point and target the following scenario where Customer Data needs to be auto populated based on the Customer ID using SharePoint Designer Workflow and OData Web Services.
Prerequisites:
- As this is going to be a List Workflow, make sure you must have a Custom List containing three columns “Customer ID”, “Full Name” and “Employer” already created on the site which you are going to select in Step 2 down the line. For the sake of this demo I have created a List with the name “Fill Customer Using Web Service” containing all the required columns.
- OData Web Service End Point http://services.odata.org/V2/Northwind/Northwind.svc should be accessible from the system which is running SharePoint Designer.
- Fiddler Web Proxy should be installed. You can get Fiddler from http://www.telerik.com/download/fiddler
Following are the steps involved in the development of Workflow Calling OData Web Service End Point:
Step-1 : Start SharePoint Designer 2013
Step-2 : Select the site in which you want to create the workflow
https://howtodowithsharepoint.files.wordpress.com/2014/05/1.png?w=450&h=183
Step-3 : Go to left navigation pane and select Workflows
https://howtodowithsharepoint.files.wordpress.com/2014/05/2.png?w=204&h=300
Step-4 : Select List Workflow [From Ribbon] > Select List [In our case it would be “Fill Customer Using Web Service”]
https://howtodowithsharepoint.files.wordpress.com/2014/05/3.png?w=372&h=300
Step-5 : On the Workflow Designer select “Call HTTP Web Service” Action from the Action Ribbon Menu
https://howtodowithsharepoint.files.wordpress.com/2014/05/4.png?w=248&h=300
Step-6 : Create the Workflow variables as shown below
https://howtodowithsharepoint.files.wordpress.com/2014/05/5.png?w=450&h=314
Step-7 : Specify the Web Service End Point, and HTTP Method as shown below
https://howtodowithsharepoint.files.wordpress.com/2014/05/6.png?w=450&h=195
Step-8 : Specify the variable of type Dictionary as placeholder for the incoming response data from the Web Service End Point
https://howtodowithsharepoint.files.wordpress.com/2014/05/7.png?w=450&h=26
Step-9 : Now before proceeding any further lets’ analyze the response from the Web Service End Point. Please note that this step is of high importance and must not be neglected. Fiddler Web Proxy is your best friend when it comes to deal with Web Services. Analysis using Fiddler will provide us with the following Vital Information out of the response
- Structure of Data returned as a part of the response
- Properties Exposed by the Web Service End Point
- Data Types of the Properties
- Additional information on Error & Exceptions (If any)
https://howtodowithsharepoint.files.wordpress.com/2014/05/8.png?w=450&h=129
Step-10 : After analyzing the data we come across the fact that we have got the required data in form of Key Value Pairs and the result set can be accessed by using the path “d/PropertyName”. So based on this knowledge we can now set the values for variable “CustomerName” & “CompanyName” using “Get an Item from a Dictionary” Action as shown below.
https://howtodowithsharepoint.files.wordpress.com/2014/05/9.png?w=450&h=56
Step-11 : As we have got the data from the Web Service End Point and stored in a set of variables, now it is time to update our list using “Set Field in Current Item” Action. We should use two instances of the same Action in order to set the value for both the fields using the variables as shown below
https://howtodowithsharepoint.files.wordpress.com/2014/05/10.png?w=329&h=300
Step-12 : With this we are good to go. Now lets’ Save the Workflow Definition, Check for the Errors and if everything is fine Publish the Workflow.
https://howtodowithsharepoint.files.wordpress.com/2014/05/13.png?w=540
https://howtodowithsharepoint.files.wordpress.com/2014/05/14.png?w=450&h=119
https://howtodowithsharepoint.files.wordpress.com/2014/05/15.png?w=540
https://howtodowithsharepoint.files.wordpress.com/2014/05/16.png?w=450&h=119
https://howtodowithsharepoint.files.wordpress.com/2014/05/17.png?w=300&h=236
Step-13 : In order to test the Workflow lets visit our List “Fill Customer Using Web Service” and quickly add a new item. We need to add the Customer ID only and rest of field will be populated by the Workflow
https://howtodowithsharepoint.files.wordpress.com/2014/05/18.png?w=450&h=197
Step-14 : Specify the Customer ID and Save the item.
https://howtodowithsharepoint.files.wordpress.com/2014/05/19.png?w=450&h=141
Step-15 : Start the Workflow on the newly added item.
https://howtodowithsharepoint.files.wordpress.com/2014/05/20.png?w=450&h=219
https://howtodowithsharepoint.files.wordpress.com/2014/05/21.png?w=450&h=92
Step-16 : And sure enough you will get the desired output with “FullName” and “Employer” Columns populated by our workflow using OData Web Service Call.
https://howtodowithsharepoint.files.wordpress.com/2014/05/22.png?w=450&h=144
Though the scenario I mentioned here is quite simple, but this new add-on to SharePoint Designer 2013 is very powerful and could be utilized to cater complex business requirements without using any need of writing modules.
Hope this will help someone in need…