4

I am using a HTTP POST call within a SharePoint 2013 Workflow to start another SharePoint 2013 workflow - I would like to know how to add a payload to pass parameters to the second workflow that I am calling?

I have 2 workflows on a list:

Workflow 1

  • Started when an item is changed

enter image description here

enter image description here

enter image description here

enter image description here

Workflow 2

  • Started Manually

enter image description here

enter image description here

enter image description here

When I change an item in the list the HTTP POST call returns a BadRequest responseCode.

Does anyone know the syntax I need to use to add the payload to the call?

2

StartWorkflowOnListItemBySubscriptionId requies complex dictionary type as payload parameter. I only did this on Visual Studio Workflow but I believe Sharepoint Designer Workflow works with this as well.

Paste below JSON string into your Request Content on Call HTTP Service

{"payload":[{"__metadata": {"type":"SP.KeyValue"},"Key":"Param1","Value":"MyValue1","ValueType":"Edm.String"},
{"__metadata":{"type":"SP.KeyValue"},"Key":"Param2","Value":"MyValue2","ValueType":"Edm.String"}]}

You can also try to change ValueType to

Edm.Int32 or Edm.Boolean.

Next, you may want to create this JSON string from your dictionary. I am not sure how it can be but below blog can be your reference as they are doing similar thing.

http://blog.vgrem.com/2014/05/08/consuming-the-sharepoint-2013-rest-service-from-sharepoint-designer/

| improve this answer | |
  • Did anybody get this working? I get a message that I can't use the { } in my workflow. – Rothrock Sep 6 '17 at 17:40
0

The required JSON POST body is already listed in the answer of Morioka:

{
    "payload":[
        {"__metadata":{"type":"SP.KeyValue"},"Key":"Param1","Value":"MyValue1","ValueType":"Edm.String"},
        {"__metadata":{"type":"SP.KeyValue"},"Key":"Param2","Value":"MyValue2","ValueType":"Edm.String"}
    ]
}

The problematic part is the payload array. When trying to manually create a dictionary with properties 0, 1, ... the keys seem to be converted to strings and the resulting JSON payload value will be an object instead of array.

The solution was posted in MS Forum:

First create a string variable (jsonPayload) and add the valid JSON array in the textfield:

[{"__metadata":{"type":"SP.KeyValue"},"Key":"Param1","Value":"MyValue1","ValueType":"Edm.String"},{"__metadata":{"type":"SP.KeyValue"},"Key":"Param2","Value":"MyValue2","ValueType":"Edm.String"}]

Then build the dictionary (reqContent): Add a property named "payload" with "Dictionary" as type. Select the workflow variable "jsonPayload" from previous step. The third readonly-field "Return field as" of the lookup popup will now display "As Dictionary from JSON".

This dictionary can now be used as variable for "Parameters for [request]" in the web service call.

You will require additional steps if you want to use dynamic values in the jsonPayload variable, because you cannot use both "{" and lookup input: add placeholders in the JSON string and replace these with your variables.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.