# URI Module instead of curl

**URL:** <https://forum.ansible.com/t/uri-module-instead-of-curl/17665>\
**Category:** Ansible Project\
**Created:** [March 4, 2015, 7:50pm UTC](https://forum.ansible.com/t/uri-module-instead-of-curl/17665 "2015-03-04T19:50:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cselden](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cselden/32/4405_2.png) [@cselden](https://forum.ansible.com/u/cselden)\
**Post date:** [March 4, 2015, 7:50pm UTC](https://forum.ansible.com/t/uri-module-instead-of-curl/17665/1 "2015-03-04T19:50:20Z")

</div>

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

---

<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:** [March 5, 2015, 12:01am UTC](https://forum.ansible.com/t/uri-module-instead-of-curl/17665/2 "2015-03-05T00:01:22Z")

</div>

Here is an example from the URI module docs:

```auto
- 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](http://docs.ansible.com/uri_module.html)

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