# Sending json to webservice not working

**URL:** <https://forum.ansible.com/t/sending-json-to-webservice-not-working/19348>\
**Category:** Ansible Project\
**Created:** [September 24, 2015, 1:35pm UTC](https://forum.ansible.com/t/sending-json-to-webservice-not-working/19348 "2015-09-24T13:35:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thecodeassassin](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@thecodeassassin](https://forum.ansible.com/u/thecodeassassin)\
**Post date:** [September 24, 2015, 1:35pm UTC](https://forum.ansible.com/t/sending-json-to-webservice-not-working/19348/1 "2015-09-24T13:35:52Z")

</div>

hey all,

I have the following variables:

```auto
vars:
  tutum_tags:
     - { "name": "web" }
     - { "name": "redis" }
     - { "name": "memcached" }

```

And the following task:

```auto
- name: Main | Parsing tutum tags
  set_fact:
    tutum_tags_json: "{{ tutum_tags|to_json }}"

- name: Debug supplied tags
  debug: msg="Set supplied tags - {{ tutum_tags_json }}"

- name: Main | Adding tags to new tutum agent
  uri:
    url: "{{ tutum_host ~ ' api/v1/node/' ~ tutum_agent_uuid ~ '/' }}"
    method: PATCH
    HEADER_Authorization: "{{ tutum_api_header }}"
    HEADER_Content-Type: "application/json"
    status_code: 201
    body: "{{ tutum_tags_json }}"

```

However it’s giving me this wonderful error:

TASK: [tutum-ansible-role | Main | Adding tags to new tutum agent] \*\*\*\*\*\*\*\*\*\*\*\*  
failed: [default] =\> {“failed”: true, “parsed”: false}  
BECOME-SUCCESS-hwnszlbrjxnztbchtlvunxntgeiksvtf  
Traceback (most recent call last):  
File “/home/vagrant/.ansible/tmp/ansible-tmp-1443101724.76-64237699457979/uri”, line 2081, in   
main()  
File “/home/vagrant/.ansible/tmp/ansible-tmp-1443101724.76-64237699457979/uri”, line 416, in main  
resp, content, dest = uri(module, url, dest, user, password, body, method, dict\_headers, redirects, socket\_timeout, validate\_certs)  
File “/home/vagrant/.ansible/tmp/ansible-tmp-1443101724.76-64237699457979/uri”, line 312, in uri  
resp, content = h.request(url, method=method, body=body, headers=headers)  
File “/usr/lib/python2.7/site-packages/httplib2/ **init**.py”, line 1608, in request  
(response, content) = self.\_request(conn, authority, uri, request\_uri, method, body, headers, redirections, cachekey)  
File “/usr/lib/python2.7/site-packages/httplib2/ **init**.py”, line 1350, in \_request  
(response, content) = self.\_conn\_request(conn, request\_uri, method, body, headers)  
File “/usr/lib/python2.7/site-packages/httplib2/ **init**.py”, line 1273, in \_conn\_request  
conn.request(method, request\_uri, body, headers)  
File “/usr/lib64/python2.7/httplib.py”, line 973, in request  
self.\_send\_request(method, url, body, headers)  
File “/usr/lib64/python2.7/httplib.py”, line 1007, in \_send\_request  
self.endheaders(body)  
File “/usr/lib64/python2.7/httplib.py”, line 969, in endheaders  
self.\_send\_output(message\_body)  
File “/usr/lib64/python2.7/httplib.py”, line 833, in \_send\_output  
self.send(message\_body)  
File “/usr/lib64/python2.7/httplib.py”, line 805, in send  
self.sock.sendall(data)  
File “/usr/lib64/python2.7/ssl.py”, line 229, in sendall  
v = self.send(data[count:])  
File “/usr/lib64/python2.7/ssl.py”, line 198, in send  
v = self.\_sslobj.write(data)  
TypeError: must be string or buffer, not list  
OpenSSH\_6.6.1, OpenSSL 1.0.1f 6 Jan 2014  
debug1: Reading configuration data /home/stephen/.ssh/config  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 19: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug1: mux\_client\_request\_session: master session id: 2  
Shared connection to 127.0.0.1 closed.

What’s weird about it is that i’m actually sending a json string and NOT a list. I cannot use body\_format since we are using Ansible 1.9.3 and not 2.x.

Does anybody know how i can fix this?
