# uri body call needs \[\] instead of {}

**URL:** <https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819>\
**Category:** Ansible Project\
**Created:** [December 13, 2019, 9:09pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819 "2019-12-13T21:09:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Britton](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Britton](https://forum.ansible.com/u/Nicholas_Britton)\
**Post date:** [December 13, 2019, 9:09pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/1 "2019-12-13T21:09:07Z")

</div>

I am working on some uri calls with netbackup and with swagger shows that it only works with but the uri modual is using {}. Any thoughts or tricks to get that to format correctly?

For example i am sending a body uri body of:

`

- name: Create MSDP Disk Pool  
uri:  
url: “{{baseurl}}storage/disk-pools”  
method: POST  
body\_format: json  
status\_code: 201  
headers:  
authorization: “{{login.json.token}}”  
content-type: application/vnd.netbackup+json;version=3.0  
body:  
data:  
type: diskPool  
attributes:  
name: server\_dpm  
diskVolumes:  
[name: PureDiskVolume]  
maximumIoStreams:  
limitIoStreams: true  
streamsPerVolume: 75  
relationships:  
storageServers:  
data:  
type: storageServer  
id: ‘PureDisk:server.domain’  
validate\_certs: no  
return\_content: yes  
register: dp\_create

`

Which produces this:

`

“body”: {  
“data”: {  
“attributes”: {  
“diskVolumes”: [  
{  
“name”: “PureDiskVolume”  
}  
],  
“maximumIoStreams”: {  
“limitIoStreams”: true,  
“streamsPerVolume”: 75  
},  
“name”: “server\_dpm”  
},  
“relationships”: {  
“storageServers”: {  
“data”: {  
“id”: “PureDisk:server.domain”,  
“type”: “storageServer”  
}  
}  
},  
“type”: “diskPool”  
}  
},

`

While swagger produces it as this:

`

working:

{  
“data”: {  
“type”: “diskPool”,  
“attributes”: {  
“name”: “server\_dpm”,  
“diskVolumes”: [  
{  
“name”: “PureDiskVolume”  
}  
],

“maximumIoStreams”: {  
“limitIoStreams”: true,  
“streamsPerVolume”: 75  
}

},  
“relationships”: {  
“storageServers”: {  
“data”: [  
{  
“type”: “storageServer”,  
“id”: “PureDisk:server.domain”  
}  
]  
}  
}  
}  
}

`

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 13, 2019, 11:16pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/2 "2019-12-13T23:16:18Z")

</div>

You’re sending something that doesn’t work, and you seem to know exactly what the problem is, and also what format _does_ work. So the solution is… send that?

Or am I missing something

---

<div class="post-metadata">

**Author:** ![Nicholas\_Britton](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Britton](https://forum.ansible.com/u/Nicholas_Britton)\
**Post date:** [December 13, 2019, 11:46pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/3 "2019-12-13T23:46:33Z")

</div>

The problem is I don’t know how to make ansible send the right bracket. Testing from swagger I know what it expects.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 14, 2019, 8:35am UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/4 "2019-12-14T08:35:24Z")

</div>

> The problem is I don't know how to make ansible send the right bracket. Testing from swagger I know what it expects.

Hello Nicholas,

try to use a list instead of a dict:

data:  
&nbsp;&nbsp;- type: storageServer  
&nbsp;&nbsp;&nbsp;&nbsp;id: 'PureDisk:server.domain'

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Nicholas\_Britton](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Britton](https://forum.ansible.com/u/Nicholas_Britton)\
**Post date:** [December 14, 2019, 1:21pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/5 "2019-12-14T13:21:56Z")

</div>

Is it the - in front of type that makes it a list over a dict?

---

<div class="post-metadata">

**Author:** ![Nicholas\_Britton](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Britton](https://forum.ansible.com/u/Nicholas_Britton)\
**Post date:** [December 14, 2019, 1:34pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/6 "2019-12-14T13:34:22Z")

</div>

When i try that i get a syntax error.

fatal: [127.0.0.1]: FAILED! =\> {  
“reason”: “Syntax Error while loading YAML.\n did not find expected ‘-’ indicator\n\nThe error appears to be in ‘/home/nbritton/ansible/gts-core-storage-operations/netbackup/tasks/msdp.create.include.yml’: line 78, column 17, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n - type: storageServer\n id: ‘PureDisk:server’\n ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n when: "ok" in result.stdout\n\nCould be written as:\n\n when: ‘"ok" in result.stdout’\n\nOr equivalently:\n\n when: "‘ok’ in result.stdout"\n”  
}

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 14, 2019, 3:19pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/7 "2019-12-14T15:19:34Z")

</div>

Hi Nicholas,

> When i try that i get a syntax error.
> 
> fatal: [127.0.0.1]: FAILED! =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"reason": "Syntax Error while loading YAML.\n

Literal style indicator of the block is missing "|"  
[https://yaml.org/spec/1.2/spec.html#id2795688](https://yaml.org/spec/1.2/spec.html#id2795688)

Try:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body: |

instead of

> \> \> body:  
> \> \> data:  
> \> \> type: diskPool  
> \> \> attributes:  
> \> \> name: server\_dpm  
> \> \> diskVolumes:  
> \> \> [name: PureDiskVolume]  
> \> \> maximumIoStreams:  
> \> \> limitIoStreams: true  
> \> \> streamsPerVolume: 75  
> \> \> relationships:  
> \> \> storageServers:  
> \> \> data:  
> \> \> type: storageServer  
> \> \> id: 'PureDisk:server.domain'

Cheers,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 14, 2019, 3:40pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/8 "2019-12-14T15:40:34Z")

</div>

Hi Nicholas,

> When i try that i get a syntax error.
> 
> fatal: [127.0.0.1]: FAILED! =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"reason": "Syntax Error while loading YAML.\n

Indentation is wrong. (Disregard my previous email.)

> \> \> body:  
> \> \> data:  
> \> \> . type: diskPool  
> \> \> . attributes:  
> \> \> . name: server\_dpm  
> \> \> . diskVolumes:  
> \> \> . [name: PureDiskVolume]  
> \> \> . maximumIoStreams:  
> \> \> . limitIoStreams: true  
> \> \> . streamsPerVolume: 75  
> \> \> .relationships:  
> \> \> .storageServers:  
> \> \> data:  
> \> \> type: storageServer  
> \> \> id: 'PureDisk:server.domain'

Cheers,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![Nicholas\_Britton](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Britton](https://forum.ansible.com/u/Nicholas_Britton)\
**Post date:** [December 14, 2019, 5:48pm UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/9 "2019-12-14T17:48:29Z")

</div>

Okay I can try that. Looks like you added a . In front of each line but the last one that needs to be a list? Did I see that correct?

---

<div class="post-metadata">

**Author:** ![Nicholas\_Britton](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@Nicholas\_Britton](https://forum.ansible.com/u/Nicholas_Britton)\
**Post date:** [December 15, 2019, 5:31am UTC](https://forum.ansible.com/t/uri-body-call-needs-instead-of/31819/10 "2019-12-15T05:31:58Z")

</div>

Thank everyone for the help. Once i lined up the - correctly it worked. That was a nice trick to learn.

relationships:  
storageServers:  
data:

- type: storageServer  
id: “PureDisk:{{mediaserver}}.{{domain}}”
