# escape single quotes

**URL:** <https://forum.ansible.com/t/escape-single-quotes/34713>\
**Category:** Ansible Project\
**Created:** [March 3, 2021, 1:30pm UTC](https://forum.ansible.com/t/escape-single-quotes/34713 "2021-03-03T13:30:32Z")\
**Posts on this page:** 1\
**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:** [March 3, 2021, 1:30pm UTC](https://forum.ansible.com/t/escape-single-quotes/34713/1 "2021-03-03T13:30:32Z")

</div>

Hello Everyone,  
I’m trying to pass the numeric values of an variable into JSON.

- name: Device ID  
set\_fact:  
“device\_id”: “{{ [device\_item\_netbox.id](http://device_item_netbox.id/) }}”

- name: DEBUG - DEVICE ID  
debug: msg=“{{ device\_id }}”

Output -

TASK [DEBUG - DEVICE ID] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\>  
msg: ‘3483’

When I try to pass the same into JSON body-

- name: Create Interface - Netbox  
uri:  
url: “{{ netbox\_url }}/api/dcim/interfaces/”  
return\_content: yes  
method: POST  
validate\_certs: false  
status\_code: 200,201  
headers:  
Authorization: “Token {{ netbox\_server\_token }}”  
body\_format: json  
body:  
{  
“device”: “{{ device\_id }}”,  
“name”: “GigabitEthernet0/0”,  
“mac\_address”: “xxxxx231”,  
“type”: “10gbase-t”,  
“enabled”: “true”,  
“description”: “GigabitEthernet0/0”  
}

Verbose output -

fatal: [localhost]: FAILED! =\> changed=false  
allow: GET, POST, HEAD, OPTIONS, TRACE  
api\_version: ‘2.8’  
content: ‘{“non\_field\_errors”:[“The fields device, name must make a unique set.”]}’  
content\_length: ‘72’  
content\_type: application/json  
elapsed: 0  
invocation:  
module\_args:  
attributes: null  
body:  
description: GigabitEthernet0/0  
device: ‘3483’  
enabled: ‘true’  
mac\_address: xxxxx231  
name: GigabitEthernet0/0  
type: 10gbase-t

But when I add something with variables like below, it removes adding quotes -

body:  
{  
“device”: “{{ device\_id }} m”,

Verbose output -

module\_args:  
attributes: null  
body:  
description: GigabitEthernet0/0  
device: 3483 m

Please advise how can I fetch/pass only numeric digits without quotes.
