# uri module - POST files

**URL:** <https://forum.ansible.com/t/uri-module-post-files/17447>\
**Category:** Ansible Project\
**Created:** [February 4, 2015, 6:48pm UTC](https://forum.ansible.com/t/uri-module-post-files/17447 "2015-02-04T18:48:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Olliver1](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@Mark\_Olliver1](https://forum.ansible.com/u/Mark_Olliver1)\
**Post date:** [February 4, 2015, 6:48pm UTC](https://forum.ansible.com/t/uri-module-post-files/17447/1 "2015-02-04T18:48:36Z")

</div>

Hi,

I have the following line but i fear the uri module is not encoding the file first and thus fails to send the file. I tried to set a variable via a command and uuencode but that also failed - any ideas or do i need to shell and use curl to post?

- uri: url=[http://localhost:8080/store.json](http://localhost:8080/store.json) method=POST body=“{{ lookup(‘file’,‘test’) }}” status\_code=200 HEADER\_Content-Type=“application/json”

test is a json file.

Thanks

Mark

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [February 4, 2015, 7:04pm UTC](https://forum.ansible.com/t/uri-module-post-files/17447/2 "2015-02-04T19:04:35Z")

</div>

Hi Olivier,

What's the error and what do you get on the server's logs?

Giovanni

---

<div class="post-metadata">

**Author:** ![Mark\_Olliver2](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Mark\_Olliver2](https://forum.ansible.com/u/Mark_Olliver2)\
**Post date:** [February 4, 2015, 8:16pm UTC](https://forum.ansible.com/t/uri-module-post-files/17447/3 "2015-02-04T20:16:50Z")

</div>

It does not get that far instead ansible tried to parse it and objects to duplicate values which is valid in this case.

---

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [February 5, 2015, 7:26pm UTC](https://forum.ansible.com/t/uri-module-post-files/17447/4 "2015-02-05T19:26:59Z")

</div>

Also, if your run the playbook in verbose mode, you’ll see what ansible is sending. This can help you determine what might be wrong with the sent data.

Also, use the ‘return\_content=yes’ on the task to see what the server is responding.

Showing us those two things can help you troubleshoot…

---

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [February 5, 2015, 7:28pm UTC](https://forum.ansible.com/t/uri-module-post-files/17447/5 "2015-02-05T19:28:30Z")

</div>

Can you show us the output… I’m guessing it’s probably some kind of quoting/yaml parsing issue.
