cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Creating a Nested Json for a REST API Post Request

pushkala
New Contributor

I am running into a very weird issue.
Big Picture - doing a bunch of operations but finally have to make a REST API call

{"field1": "random_values",
 "field2": [ { "field5": "451037", "field6": "d1"} ],
 "field3": "test",
 "field4": "True"
}

I have generated all the values through various operations - but not sure how to generate the complete payload.

Any pointers.

3 REPLIES 3

anubhav_nautiya
Contributor

can you try using a for loop for field2 in JSON generator

               "field": [
                #set($End = $length)   ## length is length of field array
                #set($Range =[0..$End])
                #foreach($i in $Range)
                        {
                        "value": {
                            "key1":[{"value":$val1[$i]}],
                            "key2":[{"value":$val2[$i]}]

                            }
                }
                #if($i != $End),

#end
#end
]

pushkala
New Contributor

Can you please share some examples