URI Module instead of curl

Hey all,

Trying to use the URI module instead of a curl command and I can’t seem to get the usage right.

Here’s the shell command:
curl -X POST --data “action=login&username={{api_user}}&password={{api_pass}}” {{api_URL}} -k

Here’s what I have for the module args but I’m not sure how to pass in the --data section

  • name: Start new API session
    uri:
    method=POST
    url={{api_URL}}
    returncontent=yes
    register: session_id_raw
    when: session_id is not defined

I’m not sure where to pass in the other flags and arguments. Any help would be much appreciated.

Thanks,
Chip

Here is an example from the URI module docs:

- uri:  url=[https://your.form.based.auth.examle.com/index.php](https://your.form.based.auth.examle.com/index.php) method=POST body="name=your_username&password=your_password&enter=Sign%20in" status_code=302 HEADER_Content-Type="application/x-www-form-urlencoded" register: login 

http://docs.ansible.com/uri_module.html

You should be able to manipulate that with your parameters to get what you need.