# Automatically putting value in bracket \[\]

**URL:** <https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175>\
**Category:** Ansible Project\
**Created:** [November 10, 2020, 1:13pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175 "2020-11-10T13:13:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pravin\_V](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pravin\_V](https://forum.ansible.com/u/Pravin_V)\
**Post date:** [November 10, 2020, 1:13pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175/1 "2020-11-10T13:13:52Z")

</div>

Hello Everyone,  
Below is the output of the task

json:  
resourceIds:

- 66523

and I’m trying to fetch the resourceIDs into the task like below.

RESOURCEID\_LIST={{ resourceID.json.resourceIds }}

But the issue is when I’m running the playbook, it is automatically putting the value in bracket   
&RESOURCEID\_LIST=[66523].

How can we input the value without putting in the bracket.

Thanks in advance.

---

<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:** [November 10, 2020, 1:32pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175/2 "2020-11-10T13:32:43Z")

</div>

Brackets is the correct way to display lists variables, which your variable apparently is.

---

<div class="post-metadata">

**Author:** ![Pravin\_V](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pravin\_V](https://forum.ansible.com/u/Pravin_V)\
**Post date:** [November 10, 2020, 1:40pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175/3 "2020-11-10T13:40:59Z")

</div>

Thank you, Dick.

Here’s the issue, I’m trying to automate device adding using Rest API, it will accept the command as below -  
url: [http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=xx6689kk&RESOURCEID\_LIST=4204&SSH\_PROFILELIST=ABC&protocolCombinationList=SSH](http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=xx6689kk&RESOURCEID_LIST=4204&SSH_PROFILELIST=ABC&protocolCombinationList=SSH)

Whereas in current situation it is automatically putting the value in the bracket as below -  
url: [http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=](http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=) xx6689kk &RESOURCEID\_LIST=[4204]&SSH\_PROFILELIST=ABC&protocolCombinationList=SSH

This way it is not working.

Please suggest what can we do in this situation.

---

<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:** [November 10, 2020, 1:48pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175/4 "2020-11-10T13:48:15Z")

</div>

> Thank you, Dick.
> 
> Here's the issue, I'm trying to automate device adding using Rest API, it will accept the command as below -  
> url:  
> [http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=xx6689kk&RESOURCEID\_LIST=4204&SSH\_PROFILELIST=ABC&protocolCombinationList=SSH](http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=xx6689kk&RESOURCEID_LIST=4204&SSH_PROFILELIST=ABC&protocolCombinationList=SSH)
> 
> Whereas in current situation it is automatically putting the value in the bracket as below -  
> url: [http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=](http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=)  
> xx6689kk &RESOURCEID\_LIST=[4204]&SSH\_PROFILELIST=ABC&protocolCombinationList=SSH  
> This way it is not working.
> 
> Please suggest what can we do in this situation.

If it is always a single value use the first element of the list:

RESOURCEID\_LIST={{ resourceID.json.resourceIds[0] }}

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

---

<div class="post-metadata">

**Author:** ![Pravin\_V](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pravin\_V](https://forum.ansible.com/u/Pravin_V)\
**Post date:** [November 10, 2020, 1:50pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175/5 "2020-11-10T13:50:23Z")

</div>

Thank you, Dick.

Here’s the issue, I’m trying to automate device adding using Rest API, it will accept the command as below -  
url: [http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=xx6689kk&RESOURCEID\_LIST=4204&SSH\_PROFILELIST=ABC&protocolCombinationList=SSH](http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=xx6689kk&RESOURCEID_LIST=4204&SSH_PROFILELIST=ABC&protocolCombinationList=SSH)

Whereas in current situation it is automatically putting the value in the bracket as below -  
url: [http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=](http://5.5.5.5/api/json/ncmsettings/assocCredential?apiKey=) xx6689kk &RESOURCEID\_LIST=[4204]&SSH\_PROFILELIST=ABC&protocolCombinationList=SSH

This way it is not working.

Like we have one filter - ipaddr, which converts the value without network like below

3.3.3.3/24

to  
3.3.3.3.

I was able to achieve the result using the below command -

{{ result.primary\_ip4.address | ipaddr (‘address’) }}

Please suggest what can we do in this situation.

Thanks,

---

<div class="post-metadata">

**Author:** ![Pravin\_V](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pravin\_V](https://forum.ansible.com/u/Pravin_V)\
**Post date:** [November 10, 2020, 9:08pm UTC](https://forum.ansible.com/t/automatically-putting-value-in-bracket/34175/6 "2020-11-10T21:08:02Z")

</div>

Thank you. That’s how I was using it, just thought to check if we have better option.
