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.
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 :).
So, to send payload body parameter could be used?
Hi,
please send that one task here, so we can see what you are actually doing, it will help to understand, thanks.
Well first of all if you check the module docs 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:
body: "{{ lookup('file','issue.json') }}"
Have you tried that?
Yes, I tried that. It worked.
Thanks.