Quantcast
Viewing latest article 8
Browse Latest Browse All 25

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
Image may be NSFW.
Clik here to view.
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
Image may be NSFW.
Clik here to view.
siteapppermissions

Copy the GUID in the middle, indicated by the thin red box in the image below:
Image may be NSFW.
Clik here to view.
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):

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

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:
Image may be NSFW.
Clik here to view.
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!


Viewing latest article 8
Browse Latest Browse All 25

Trending Articles