# URI module cannot use body and src together

**URL:** <https://forum.ansible.com/t/uri-module-cannot-use-body-and-src-together/35195>\
**Category:** Ansible Developer\
**Created:** [May 19, 2021, 3:49pm UTC](https://forum.ansible.com/t/uri-module-cannot-use-body-and-src-together/35195 "2021-05-19T15:49:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilber\_H](https://avatars.discourse-cdn.com/v4/letter/w/df788c/32.png) [@Wilber\_H](https://forum.ansible.com/u/Wilber_H)\
**Post date:** [May 19, 2021, 3:49pm UTC](https://forum.ansible.com/t/uri-module-cannot-use-body-and-src-together/35195/1 "2021-05-19T15:49:01Z")

</div>

Hi,

URI module cannot use body and src together.

Binary file and body parameter cannot be posted.

I’ve tried to make this work but can’t find any Ansible documentation stating how to do this using the URI module. I’m able to use curl with the SHELL module, but not ideal approach.  
Any guidance would be appreciate it.

Regards,  
Wilber H

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 19, 2021, 3:52pm UTC](https://forum.ansible.com/t/uri-module-cannot-use-body-and-src-together/35195/2 "2021-05-19T15:52:25Z")

</div>

It sounds like you are trying to do a multipart post. In which case, just use body, and follow the example named “Upload a file via multipart/form-multipart”

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html)

---

<div class="post-metadata">

**Author:** ![Wilber\_H](https://avatars.discourse-cdn.com/v4/letter/w/df788c/32.png) [@Wilber\_H](https://forum.ansible.com/u/Wilber_H)\
**Post date:** [May 20, 2021, 3:20am UTC](https://forum.ansible.com/t/uri-module-cannot-use-body-and-src-together/35195/3 "2021-05-20T03:20:36Z")

</div>

Hi Matt,

I followed the steps in the section and tried several combinations of it and still get this message or something similar -

“msg”: “value of the body\_format must be one of: form-urlencoded, json, raw, got: form-multipart”

\*note: this is the body section of the URI module/task -  
file1:  
filename: “somefilename.bin”  
mime\_type: application/octet-stream  
todo: “dosomething”

\*But when I decide to use the SHELL module and the curl command it works -  
curl -X POST --url [https://someaddress/worktodo](https://someaddress/worktodo)  
-k  
-H ‘Accept-Type: application/json’ \

-H ‘Content-Type: multipart/form-data’ \

-H 'Cookie: ‘somecookie’ \

-F ‘todo=dosomething’

-F ‘binaryfile=@somefilename.bin’
