URI module cannot use body and src together

614 views
Skip to first unread message

Wilber H

unread,
May 19, 2021, 11:49:01 AM5/19/21
to Ansible Development
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

Matt Martz

unread,
May 19, 2021, 11:53:06 AM5/19/21
to Wilber H, Ansible Development
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"


--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/6c4481bf-f132-42f5-9f3a-15bf9f7dc9efn%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net

Wilber H

unread,
May 19, 2021, 11:20:36 PM5/19/21
to Ansible Development
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
                       -k
                       -H 'Accept-Type: application/json' \
                       -H 'Content-Type: multipart/form-data' \
                       -H 'Cookie: 'somecookie' \
                       -F 'todo=dosomething'
                       -F 'binaryfile=@somefilename.bin'
Reply all
Reply to author
Forward
0 new messages