cancel
Showing results for 
Search instead for 
Did you mean: 

How to Configure a collection to Web API request with JSON template?

Mani
Level 4
How to map a collection to Web API request with JSON template?
From example I have the following JSON Template & I want ot map it to collection:

{
"SourceFiles": [
{
"Field1": "[Field1Value]",
"Field2": "[Field2Value]",

}
]
}


I have a collection which have values of "Field1" and "Field2".
How I can map the collection values to the above template?



Thanks in advance

------------------------------
Mani K
------------------------------
2 REPLIES 2

ewilson
Staff
Staff
Hi @Mani,

When you say you want to map the Collection what are you trying to do? Figure out if you can serialize a Collection straight to JSON? If so, are you using the Utility - JSON VBO?

The action Collection to JSON of the Utility - JSON VBO will take an input Collection and convert it to JSON. However, it treats a Collection as a JSON array of objects. In other words, every row in the Collection is looked at as a JSON object. Here's an example.

Example:

What we have below is a top-level Collection with a single field titled SourceFiles with a field type of Collection. That Collection then has it's own definition which is two fields named Field1 and Field2 each with type Text.

Collection Definition
31949.png
31950.png
When we run this Collection through the Collection to JSON action, we receive the following JSON as output.

[
	{
		"SourceFiles": [
			{
				"Field1": "SourceFile:Row1-Field1:Row1",
				"Field2": "SourceFile:Row1-Field2 Row1"
			},
			{
				"Field1": "SourceFile:Row1-Field1:Row2",
				"Field2": "SourceFile:Row1-Field2:Row2"
			}
		]
	}
]
 
Since you don't want to top-level array definition, you could always remove the top-level brackets with simple string manipulation.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Thanks a lot Eric Wilson,
I'll try in my process as you guided. This is really helpful, I was expecting this only.

------------------------------
Mani K
------------------------------