I'm trying to build an HTTP request to a service which accepts a list of items, for example:
{
"user": "john",
"table": "goods",
"articles": [
{"id": "003", "quantity": 1},
{"id": "004", "quantity": 1},
{"id": "023", "quantity": 2},
{"id": "011", "quantity": 3},
{"id": "063", "quantity": 1},
{"id": "006", "quantity": 7}
]
}
My goal is to load ALL the articles from a CSV file, done as follows:
I would like to have something like:
{
"user": "john",
"table": "goods",
"articles": [
{"id": "${id}", "quantity": ${qte}}
]
}
Can anyone help me?
UPDATE:
Dmitri T solved my problem, thank you! I also asked him how to add a JSON object (a dictionary) to my body, while he answer I found a solution which I will share here in case someone needs it. If you want to add:
"user": {"id": 1, "name": "John"}
to your body content, you just need to do this:
def user = [:]
//populate user
user.put('id', 1)
user.put('name', 'John')
//add user entity to body content
content.put("user", user)
Have fun!
