Automatically putting value in bracket []

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.

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

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

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= xx6689kk &RESOURCEID_LIST=[4204]&SSH_PROFILELIST=ABC&protocolCombinationList=SSH

This way it is not working.

Please suggest what can we do in this situation.

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

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=
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
       Racke

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

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= 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,

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