# Issue with URI module in ansible1.9-1.9.6-2

**URL:** <https://forum.ansible.com/t/issue-with-uri-module-in-ansible1-9-1-9-6-2/21462>\
**Category:** Ansible Developer\
**Created:** [May 17, 2016, 7:50pm UTC](https://forum.ansible.com/t/issue-with-uri-module-in-ansible1-9-1-9-6-2/21462 "2016-05-17T19:50:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guillaume\_Belrose](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Guillaume\_Belrose](https://forum.ansible.com/u/Guillaume_Belrose)\
**Post date:** [May 17, 2016, 7:50pm UTC](https://forum.ansible.com/t/issue-with-uri-module-in-ansible1-9-1-9-6-2/21462/1 "2016-05-17T19:50:50Z")

</div>

Hi all,

I am on CentOS 6.7 using Ansible 1.9 and I’ve updated my version of Ansible to be ansible1.9-1.9.6-2 (retrieved from EPEL).

I have some tasks ([1]) which upload (via POST) dashboards to Grafana. Those tasks used to run just fine in the previous version of Ansible (4-2) but with the most recent release of the 1.9 branch, they fail with an error ([2]).

[1]

- name: import the Cluster dashboards  
uri:  
url: [http://127.0.0.1:3000/api/dashboards/db](http://127.0.0.1:3000/api/dashboards/db)  
method: POST  
body: “{{ lookup(‘file’, ‘/tmp/cluster.json’) }}”  
body\_format: json  
HEADER\_Content-Type: “application/json”  
user: admin  
password: admin  
force\_basic\_auth: yes

[2]

TASK: [grafana-2-dashboards | import the Cluster dashboards] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [10.165.1.41] =\> {“failed”: true, “parsed”: false}  
BECOME-SUCCESS-pjcvvpproqvedvdzjlxsjvwndajwkzee  
Traceback (most recent call last):  
File “/root/.ansible/tmp/ansible-tmp-1463513575.1-256930227119349/uri”, line 2106, in   
main()  
File “/root/.ansible/tmp/ansible-tmp-1463513575.1-256930227119349/uri”, line 415, in main  
resp, content, dest = uri(module, url, dest, user, password, body, method, dict\_headers, redirects, socket\_timeout, validate\_certs)  
File “/root/.ansible/tmp/ansible-tmp-1463513575.1-256930227119349/uri”, line 311, in uri  
resp, content = h.request(url, method=method, body=body, headers=headers)  
File “/usr/lib/python2.6/site-packages/httplib2/ **init**.py”, line 1605, in request  
(response, content) = self.\_request(conn, authority, uri, request\_uri, method, body, headers, redirections, cachekey)  
File “/usr/lib/python2.6/site-packages/httplib2/ **init**.py”, line 1353, in \_request  
(response, content) = self.\_conn\_request(conn, request\_uri, method, body, headers)  
File “/usr/lib/python2.6/site-packages/httplib2/ **init**.py”, line 1290, in \_conn\_request  
conn.request(method, request\_uri, body, headers)  
File “/usr/lib64/python2.6/httplib.py”, line 936, in request  
self.\_send\_request(method, url, body, headers)  
File “/usr/lib64/python2.6/httplib.py”, line 976, in \_send\_request  
self.send(body)  
File “/usr/lib64/python2.6/httplib.py”, line 781, in send  
self.sock.sendall(str)  
File “”, line 1, in sendall  
TypeError: sendall() argument 1 must be string or buffer, not dict  
OpenSSH\_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug1: mux\_client\_request\_session: master session id: 2  
debug1: mux\_client\_request\_session: master session id: 2

I would appreciate any pointers to help me debug this.

Thanks in advance for your help.

Guillaume.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [May 18, 2016, 9:38am UTC](https://forum.ansible.com/t/issue-with-uri-module-in-ansible1-9-1-9-6-2/21462/2 "2016-05-18T09:38:54Z")

</div>

I think uri may have changed and it might not be necessary to set the  
HEADER\_Content-Type  
any more now that you are setting body\_format: json

Also I’ve seen elsewhere that you may need to insert a space to avoid a type conversion problem.

Try changing

body: “{{ lookup(‘file’, ‘/tmp/cluster.json’) }}”

to

body: " {{ lookup(‘file’, ‘/tmp/cluster.json’) }}"

If that doesn’t work and you get past the stracktrace then I suggest trying something like wireshark to inspect what uri actually sends.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Guillaume\_Belrose](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Guillaume\_Belrose](https://forum.ansible.com/u/Guillaume_Belrose)\
**Post date:** [May 18, 2016, 12:33pm UTC](https://forum.ansible.com/t/issue-with-uri-module-in-ansible1-9-1-9-6-2/21462/3 "2016-05-18T12:33:52Z")

</div>

Hi Jon,

Wow, many thanks for your help, adding the space was enough to fix the issue!!!  
Do you happen to know if there is a more intuitive way of preventing the type conversion ? Maybe applying a filter ?  
In 1.9, I actually think the body\_format option is not supported, so I have to specify the content type.  
I owe you big time for your help.

Guillaume.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [May 18, 2016, 2:53pm UTC](https://forum.ansible.com/t/issue-with-uri-module-in-ansible1-9-1-9-6-2/21462/4 "2016-05-18T14:53:30Z")

</div>

Hi Guillaume,

Pretty much everything I know about this issue is from the discussion on this thread: [https://groups.google.com/forum/#!topic/ansible-devel/2C7pl2\_kxlY](https://groups.google.com/forum/#!topic/ansible-devel/2C7pl2_kxlY)

Jon
