# dynamic json syntax issue

**URL:** <https://forum.ansible.com/t/dynamic-json-syntax-issue/18759>\
**Category:** Ansible Project\
**Created:** [July 14, 2015, 4:32pm UTC](https://forum.ansible.com/t/dynamic-json-syntax-issue/18759 "2015-07-14T16:32:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phill\_Pafford](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@Phill\_Pafford](https://forum.ansible.com/u/Phill_Pafford)\
**Post date:** [July 14, 2015, 4:32pm UTC](https://forum.ansible.com/t/dynamic-json-syntax-issue/18759/1 "2015-07-14T16:32:24Z")

</div>

I’m trying to dynamically create the JSON response needed for my REST request, I can hard code the JSON var and it works but when I add a variable it fails.

```auto
- name: add ssh key to stash via api
  uri:
    url: "{{stash_api_url}}"
    user: "{{stash_username}}"
    password: "{{stash_password}}"
    force_basic_auth: yes
    method: POST
    body: '''{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}'''
    body_format: json
    status_code: 201,409
    HEADER_Content-Type: "application/json"
    register: ssh_key_added_to_stash
    when: stash_ansible_ssh_key_contents.stdout != -1

```

```auto

```

```auto
tried:

```

```auto
- body: '{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}'

```

```auto
- body: ''{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}''

```

```auto
- body: '''{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}'''

```

```auto

```

```auto
if I reverse the single and double quotes there is still an issue

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Phill\_Pafford](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@Phill\_Pafford](https://forum.ansible.com/u/Phill_Pafford)\
**Post date:** [July 14, 2015, 4:33pm UTC](https://forum.ansible.com/t/dynamic-json-syntax-issue/18759/2 "2015-07-14T16:33:30Z")

</div>

Hardcoding this works:

{  
“text”: “my value here”  
}
