# Can't render JSON via lookup and POST via uri module

**URL:** <https://forum.ansible.com/t/cant-render-json-via-lookup-and-post-via-uri-module/19868>\
**Category:** Ansible Project\
**Created:** [November 26, 2015, 6:19pm UTC](https://forum.ansible.com/t/cant-render-json-via-lookup-and-post-via-uri-module/19868 "2015-11-26T18:19:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Gilbert](https://avatars.discourse-cdn.com/v4/letter/g/a698b9/32.png) [@Greg\_Gilbert](https://forum.ansible.com/u/Greg_Gilbert)\
**Post date:** [November 26, 2015, 6:19pm UTC](https://forum.ansible.com/t/cant-render-json-via-lookup-and-post-via-uri-module/19868/1 "2015-11-26T18:19:17Z")

</div>

Hi, all. I opened a ticket about this but was redirected here.

Basically, I’m having an issue where using lookup to render a template that gets passed into the uri module’s body parameter does not work. It throws an TypeError: unhashable type error.

Here’s the task I’m running:

- name: Post  
uri:  
url: [https://hooks.slack.com/endpoint](https://hooks.slack.com/endpoint)  
method: POST  
return\_content: no  
HEADER\_Content-Type: “application/json”  
body: “{{ lookup(‘template’, ‘…/templates/my.json.j2’, convert\_data=False) }}”

with this in my.json.j2:

{  
“channel”: “chatops”,  
“username”: “Deploy”,  
“text”: “TEST Deploy!”  
}

Folding the JSON into a single line within the template has the same effect. Piping the lookup response through to\_json also does not work. Taking the folded JSON and using it directly in the play does work, however.

For context, this is Ansible 1.9.4 running on OSX 10.11.1. Thanks!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 27, 2015, 6:59pm UTC](https://forum.ansible.com/t/cant-render-json-via-lookup-and-post-via-uri-module/19868/2 "2015-11-27T18:59:27Z")

</div>

First of all, there is no need to use the template function here,  
there is just pure json not a jinja2 template that generates json, the  
'file' lookup should work just fine.

As per the module docs, the default format is raw, it seems you should  
be set body\_type to json.

Also what version of ansible are you using? the json format is only  
recently supported.
