Complete Guide to Making and Parsing REST calls using SharePoint Designer 2013

Recently I needed a sequential workflow that makes a REST call to another website (non-SharePoint), retrieves some JSON data, parses it, and makes decisions based on that data. Oh, and I’m not allowed to use Visual Studio in this case, it has to be SharePoint Designer (ugh).

I’m familiar with the Call Web Service action in SPD2013, but for some reason it wouldn’t behave. After searching around for a bit I uncovered a few other things in various locations that needed attention. I’m consolidating that research into one blog post to keep things simple. Here goes:

Making REST call in SPD2013

First, create a Build a Dictionary action and set the following values:
Accept String application/json;odata=verbose
Content-Type String application/json;odata=verbose
Authorization String (leave empty)

Next, consider putting the following step into an App Step. To add this to an App Step requires several things be done in advance:

Enabling App Step in SPD2013

First, go to Site Settings->Manage Site Features, and ensure the “Workflow Can Use App Permissions” feature is activated
workflowapppermissions

Then, you’ll need to make sure the workflow has the right app permissions. Go back to Site Settings, and under People and Groups click on Site App Permissions
siteapppermissions

Copy the GUID in the middle, indicated by the thin red box in the image below:
appid

Navigate to http://server/site/_layouts/15/AppInv.aspx (your sharepoint site, adding the AppInv.aspx at the end), enter the GUID you just copied from the previous step, paste it into the App ID box and click Lookup. All the fields should populate except the Permission Request XML. Paste the following in that field (DO NOT EDIT, paste exactly as is):


    

Click Create and you should be prompted with “Do you trust this app?”. Click Trust It, and you’re now ready to use the App Step in SPD2013 (whew!)

Making REST call in SPD2013 (continued)

Next, create a Call a Web Service action (inside of the App Step if desired), right click on it and choose Properties. Populate the fields as follows:
sample

Ok, with all that done to read the results of the response, create a Get an Item From a Dictionary action. The item you’re getting is based on how your JSON hierarchy is constructed. For example, many sites nest their JSON results like “d”:”{“results”:”{“key”:”value”}”}”. In this case, your Get an Item value would be d/Results/Key. You may need to experiment with this value based on each individual site’s JSON response.

You should now be able to put this value in a variable and continue with your workflow based on the response value you captured! Hope this helps!

Short URL: http://eoszak.me/1psmTpd

Eric

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Leave a Reply