Complex api json calls

I am looking to use the uri module and have been sucessfull with simpler calls, but i am unsure how to get something like the following to work correctly. I have been provided what the json should look like but i am unsure how to build that out via the uri module in the body syntax.

I have also struggled to find how ansible handles nested levels in the body. from examples it looks like its just the indents. But i am not sure, if someone can help shed some light for me it would be much appreciated.

Here is what the json should look like when sent as the payload:

`
POST https://fsunix005.pne.ven.veritas.com/netbackup/config/snapshotproviders/configuredplugins/aws/instances

{

“data”: {

“id”: “someid”,

“type”: “plugininstance”,

“attributes”: {

“configurationAttributes”: [

{

“name”: “accesskey”,

“singlevalue”: “key1”

},

{

“name”: “secretkey”,

“singlevalue”: “skey2”

},

{

“name”: “regions”,

“multivalue”: [

“us-east-1”,

“us-east-2”,

“us-west-1”,

“us-west-2”

]

}

]

}

}

}
`

The body is typically easiest represented as a YAML representation of the JSON data format. So in your case, this should be what you need:

So if the multivalue is driven from user input or an input file and will vary in what regions are to be used, how can that be dynamic?

If you look in the documentation you'll see that you can use json in body by setting body_format.

File:
  body: "{{ lookup('file', '/path/to/json/file.json' }}"

Variable
  body: "{{ myvar.json }}"