Is there a way to build a json array in a SharePoint designer workflow?

I'm trying to update a multi-value lookup field in a SharePoint 2013 list from a SharePoint designer workflow using the 'Call HTTP Web Service' action.

Here's how the field looks when querying a list item with two values:

    "Assigned_x0020_toId":{"__metadata":{"type":"Collection(Edm.Int32)"},"results":[1,2]}

I'm using nested dictionaries to create the json structure for the POST request within SharePoint Designer but I'm not sure how to create a JSON array as needed by the "results" field.

I'm reading the "Assigned to" field from another list into a workflow variable typed as "Lookup Ids, comma delimited".

I then create a dictionary with an item "results" and the value set to my comma delimited lookup ids variable.

The json this produces is:

    "Assigned_x0020_toId":{"results":1}

I get the following error when executing the query:

An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartArray' node was expected.

I think that's because the query should be:

    "Assigned_x0020_toId":{"results":[1]}

Can anybody help me achieve that in SharePoint designer or suggest a better alternative?

The reason I'm using the web service is that I'm trying to create a workflow that loops through all of a list's items updating values when changes are made in another list.

May 27th, 2015 2:21pm

Hi,

According to your description, my understanding is that you want to build a array for the Json format result data when using workflow call web service.

In the workflow, I suggest you can count Items in the Results and output to a variable, then you can use Loop action to loop through the results with the count.

Here is a detailed article for your reference:

DOING COOL THINGS WITH SHAREPOINT 2013S CALL HTTP WEB SERVICE WORKFLOW ACTION

Thanks

Best Regards

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 9:50pm

Thanks for the reply Jerry, I can read values without any problem but the issue comes when trying to write values back through the web service. I'm having trouble finding a way to create a query in sharepoint designer 2013 that is formatted like this:

"Assigned_x0020_toId":{"results":[1]}

For example if I build a string for the array of results, designer produces the following query:

"Assigned_x0020_toId":{"results":"[1]"}

Which results in an error.
June 26th, 2015 10:42am

Hi Snehpetsa, did you ever manage to figure this out?   I've also hit this issue in that I have a WebAPI POST which takes a json array as a parameter, however I haven't been able to get SharePoint Designer to correctly generate the syntax.

Regards

Free Windows Admin Tool Kit Click here and download it now
July 27th, 2015 5:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics