# Need Help for REST API integration with Ansible

**URL:** <https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846>\
**Category:** Ansible Project\
**Created:** [July 23, 2019, 12:38pm UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846 "2019-07-23T12:38:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [July 23, 2019, 12:38pm UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/1 "2019-07-23T12:38:41Z")

</div>

There is URI module present in Ansible which lets you invoke REST End Points and it works preety well.  
Currently i have lot of JSON Objects and corresponding REST end points ofcourse for each.  
Is it a good practice for each and every parameter inside a JSON object (which is model object for REST service) configurable via jinja template in Ansible rather than POSTing complete Payload to a base URL from a file?  
I mean it can be huge parameters if we make each service payload parameter as variable in ansible.  
Customer demand is : they want each and every parameter used for REST API configurable via Ansible.  
I dont know is it good or bad, for me it is not good practice.

Rahul

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [July 30, 2019, 9:37am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/2 "2019-07-30T09:37:48Z")

</div>

Any experts view on this ?

---

<div class="post-metadata">

**Author:** ![Andrew\_Feller](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@Andrew\_Feller](https://forum.ansible.com/u/Andrew_Feller)\
**Post date:** [July 30, 2019, 9:48am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/3 "2019-07-30T09:48:52Z")

</div>

You really should consider developing a plugin for this rather than twisting YAML to make it happen. Check out [https://docs.ansible.com/ansible/latest/dev\_guide/developing\_plugins.html](https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html) for writing this in Python in a way that’s callable from Ansible

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [July 30, 2019, 9:51am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/4 "2019-07-30T09:51:31Z")

</div>

Thanks Andrew , but is it good to make each and every parameter of Rest api response as configurable using Ansible , considering we have huge parameters?

---

<div class="post-metadata">

**Author:** ![Mark\_Anthony\_Garcia](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@Mark\_Anthony\_Garcia](https://forum.ansible.com/u/Mark_Anthony_Garcia)\
**Post date:** [July 30, 2019, 9:58am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/5 "2019-07-30T09:58:30Z")

</div>

It is best to use jinja template to create the bosy file and call it for scalability. This is what I do using data from mssql query.

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [July 30, 2019, 10:12am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/6 "2019-07-30T10:12:32Z")

</div>

> There is URI module present in Ansible which lets you invoke REST End Points and it works preety well.  
> Currently i have lot of JSON Objects and corresponding REST end points ofcourse for each.  
> Is it a good practice for each and every parameter inside a JSON object (which is model object for REST service) configurable via jinja template in Ansible rather than POSTing complete Payload to a base URL from a file?

Take a look at modules in Kubernetes space for handling module parameters.

> I mean it can be huge parameters if we make each service payload parameter as variable in ansible.  
> Customer demand is : they want each and every parameter used for REST API configurable via Ansible.

You may want to write plugin for this. Take a look at httpapi plugin for such requirement - [https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/httpapi](https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/httpapi)

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [July 30, 2019, 10:28am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/7 "2019-07-30T10:28:07Z")

</div>

Thanks abhijeet .

- [https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/httpapi](https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/httpapi) - What this plugin does , any usage , as i dont see any readme file also? or i need to look at its code?

Regards  
Rahul

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rahul\_Kumar1](https://forum.ansible.com/u/Rahul_Kumar1)\
**Post date:** [September 5, 2019, 5:13am UTC](https://forum.ansible.com/t/need-help-for-rest-api-integration-with-ansible/30846/8 "2019-09-05T05:13:35Z")

</div>

I think purpose of httpapi plugin is different. Here I have my own API (say built in JAX-RS or Spring Boot), and list of REST ends points are of order (10-100) where each Resource have multiple parameters to deal with.  
In that context , is it good to make each param configurable using ansible?
