# Send payload using uri module

**URL:** <https://forum.ansible.com/t/send-payload-using-uri-module/19503>\
**Category:** Ansible Project\
**Created:** [October 14, 2015, 10:59am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503 "2015-10-14T10:59:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [October 14, 2015, 10:59am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/1 "2015-10-14T10:59:29Z")

</div>

I am trying to **send a payload(in JSON)** to a destination mentioned in the URL. For this purpose I am using **uri module and POST method**. How can I send it using uri module? I am using ansible **version 1.9.1** and when I tried to use **body parameter** for uri module it shows the following error: **body is not a legal parameter in an Ansible task or handler**.

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [October 14, 2015, 11:03am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/2 "2015-10-14T11:03:07Z")

</div>

Hi,

this error usually means problem in indentation, body souhld be two spaces deeper I guess. But cannot be sure, as you have not sent your task here :).

---

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [October 14, 2015, 11:05am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/3 "2015-10-14T11:05:41Z")

</div>

So, to send payload body parameter could be used?

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [October 14, 2015, 11:11am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/4 "2015-10-14T11:11:50Z")

</div>

Hi,

please send that one task here, so we can see what you are actually doing, it will help to understand, thanks.

---

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [October 14, 2015, 12:22pm UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/5 "2015-10-14T12:22:21Z")

</div>



---

<div class="post-metadata">

**Author:** ![igorc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/igorc/32/5491_2.png) [@igorc](https://forum.ansible.com/u/igorc)\
**Post date:** [October 21, 2015, 4:18am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/6 "2015-10-21T04:18:08Z")

</div>

Well first of all if you check the module docs [http://docs.ansible.com/ansible/uri\_module.html](http://docs.ansible.com/ansible/uri_module.html) you can see that body\_format was introduced in ansible 2.0 so you can't use it in 1.9.1

It also shows an example of supplying the json file to the body parameter that looks much cleaner than what you are trying to do:

&nbsp;&nbsp;&nbsp;&nbsp;body: "{{ lookup('file','issue.json') }}"

Have you tried that?

---

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [October 21, 2015, 4:33am UTC](https://forum.ansible.com/t/send-payload-using-uri-module/19503/7 "2015-10-21T04:33:55Z")

</div>

Yes, I tried that. It worked.

Thanks.
