Tuesday 19 November 2013

Have a REST with SharePoint Designer 2013 Workflow

SharePoint Designer 2013 provides a new set of actions including, finally, the ability to call REST services – sadly I find this feature truly exiting. It even works on SharePoint Online (within limits).

The brief example below will add a row to the MyBikes list. The status entries, log entries and emails can all be ignored.

The rest call will be an HTTP POST to the following method: https://<web>/sites/intranet/_api/web/lists/getbytitle('MyBikes')/items

Ensure that you check the REST URL first to ensure it is correct, running it through Fiddler and checking the JSON is very useful.

  1. Fire up SharePoint Designer.
  2. Create a site workflow.
  3. Create the Dictionary for the Header, the Metadata and the Parameters (see below).

image
Figure 0 – The workflow.

image
Figure 1 – The header contains the Accept and Content-Type definitions set to application/json;odata=verbose.

image
Figure 2 – The metadata indicated the list specific call. Worth checking this with Fiddler.

image
Figure 3 – The parameters binds to the metadata and defined the columns to be updated.

image
Figure 4 – Construct the REST call, binding the parameters, and the header (via properties).

image

Publish. Navigate to Site Content and manually execute - Heh presto a new row is added to the list.

No comments:

Post a Comment