# Why cannot retrieve or launch a Workflow Job Template by using Tower API?

**URL:** <https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101>\
**Category:** AWX Project\
**Created:** [November 22, 2017, 4:41am UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101 "2017-11-22T04:41:18Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![leima2046](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@leima2046](https://forum.ansible.com/u/leima2046)\
**Post date:** [November 22, 2017, 4:41am UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/1 "2017-11-22T04:41:18Z")

</div>

I tried to launch a Workflow Template on Ansible Tower by calling the APIs. But cannot even get the template information using [https://towerIP/api/v2/job\_templates/workflowtemplatename](https://towerip/api/v2/job_templates/workflowtemplatename). Not mention to launch it. It works fine with those Job Templates. Does anyone know why it cannot work? Or did I just misuse it?

Thanks,

---

<div class="post-metadata">

**Author:** ![jmitchel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jmitchel/32/10148_2.png) [@jmitchel](https://forum.ansible.com/u/jmitchel)\
**Post date:** [November 22, 2017, 3:08pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/2 "2017-11-22T15:08:53Z")

</div>

![](https://mail.google.com/mail/u/3/images/cleardot.gif)

I believe that that the endpoint is unified\_job\_templates, not job\_templates.

For future reference, you point a browser to [https://towerIP/api/v2](https://towerIP/api/v2), you’ll get a clickable tree of the available routes.

---

<div class="post-metadata">

**Author:** ![Bill\_Nottingham1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@Bill\_Nottingham1](https://forum.ansible.com/u/Bill_Nottingham1)\
**Post date:** [November 22, 2017, 3:14pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/3 "2017-11-22T15:14:32Z")

</div>

leima2046@gmail.com (leima2046@gmail.com) said:

> I tried to launch a Workflow Template on Ansible Tower by calling the APIs.  
> But cannot even get the template information using  
> [https://towerIP/api/v2/job\_templates/workflowtemplatename](https://towerIP/api/v2/job_templates/workflowtemplatename)  
> \<[https://towerip/api/v2/job\_templates/workflowtemplatename&gt;\](https://towerip/api/v2/job_templates/workflowtemplatename&gt;%5C). Not mention to  
> launch it. It works fine with those Job Templates. Does anyone know why it  
> cannot work? Or did I just misuse it?

Workflow templates aren't under job\_templates, they're under their own API  
endpoint.

Bill

---

<div class="post-metadata">

**Author:** ![mabashia](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mabashia](https://forum.ansible.com/u/mabashia)\
**Post date:** [November 22, 2017, 3:28pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/4 "2017-11-22T15:28:22Z")

</div>

Just gonna add a bit of extra info to what’s already been said - Workflow Job Templates and Job Templates are returned jointly via /api/v2/unified\_job\_templates but they each have their own endpoints (/api/v2/job\_templates and /api/v2/workflow\_job\_templates). To launch a workflow via the api you’ll need to hit /api/v2/workflow\_job\_templates/N/launch/ where N is the id of the workflow job template.

---

<div class="post-metadata">

**Author:** ![AlanCoding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alancoding/32/301_2.png) [@AlanCoding](https://forum.ansible.com/u/AlanCoding)\
**Post date:** [November 27, 2017, 4:50pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/5 "2017-11-27T16:50:43Z")

</div>

Normally, you would access a WFJT (workflow job template) by its primary key like [http://tower.invalid/api/v2/workflow\_job\_templates/38/](http://tower.invalid/api/v2/workflow_job_templates/38/)

However, you can use its named url. To do this, navigate to its detail view (like the prior link) and see the entry “named\_url” under “related”.  
In my case, I named my WFJT “asdf”, but it exists in the “Default” organization.  
Names are only unique within a single organization, thus the named URL is a combination of both names.  
Thus, the named URL for my WFJT looks like: [http://tower.invalid/api/v2/workflow\_job\_templates/asdf++Default/](http://tower.invalid/api/v2/workflow_job_templates/asdf++Default/)

---

<div class="post-metadata">

**Author:** ![jmitchel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jmitchel/32/10148_2.png) [@jmitchel](https://forum.ansible.com/u/jmitchel)\
**Post date:** [November 28, 2017, 7:25pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/6 "2017-11-28T19:25:15Z")

</div>

Hey Lei,  
Just a note to reply with [awx-project@googlegroups.com](mailto:awx-project@googlegroups.com) so that people subscribed to the list can see your question/answer as well.

I’m not sure off the top of my head how the API works in terms of extra vars and workflow nodes, Alan and Mike probably know.

---

<div class="post-metadata">

**Author:** ![leima2046](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@leima2046](https://forum.ansible.com/u/leima2046)\
**Post date:** [November 28, 2017, 10:53pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/7 "2017-11-28T22:53:13Z")

</div>

Hi, John,

Thank you.

Alan, Mike or anybody else who knows how to provide “extra variables” in the payload for each node in a workflow template job?

Thanks,

Lei

---

<div class="post-metadata">

**Author:** ![Bill\_Nottingham1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@Bill\_Nottingham1](https://forum.ansible.com/u/Bill_Nottingham1)\
**Post date:** [November 29, 2017, 12:36am UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/8 "2017-11-29T00:36:47Z")

</div>

Lei Ma (leima2046@gmail.com) said:

> Hi, John,
> 
> Thank you.
> 
> Alan, Mike or anybody else who knows how to provide "extra variables" in  
> the payload for each node in a workflow template job?

As in different vars at launch time to each node? You don't.

Bill

---

<div class="post-metadata">

**Author:** ![leima2046](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@leima2046](https://forum.ansible.com/u/leima2046)\
**Post date:** [November 29, 2017, 12:44am UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/9 "2017-11-29T00:44:13Z")

</div>

Yes, exactly what I need. Don’t quite understand what you mean. There are definitely similar demands in practice. For my case, I need to drive a 3rd party platform by calling its APIs using URI module. And need to provide payload based on the user’s input each time. What will you do in this case?

Thanks,

Lei

---

<div class="post-metadata">

**Author:** ![Bill\_Nottingham1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@Bill\_Nottingham1](https://forum.ansible.com/u/Bill_Nottingham1)\
**Post date:** [November 29, 2017, 1:00am UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/10 "2017-11-29T01:00:05Z")

</div>

Lei Ma (leima2046@gmail.com) said:

> Yes, exactly what I need. Don't quite understand what you mean. There are  
> definitely similar demands in practice. For my case, I need to drive a 3rd  
> party platform by calling its APIs using URI module. And need to provide  
> payload based on the user's input each time. What will you do in this case?

I mean it's not a feature that's supported. There is no way to pass, at  
launch time, variables for inidividual workflow components.

extra\_vars can be passed to the workflow as a whole; those extra vars passed  
to the workflow are passed to all job templates in the workflow.

Bill

---

<div class="post-metadata">

**Author:** ![AlanCoding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alancoding/32/301_2.png) [@AlanCoding](https://forum.ansible.com/u/AlanCoding)\
**Post date:** [November 29, 2017, 1:13pm UTC](https://forum.ansible.com/t/why-cannot-retrieve-or-launch-a-workflow-job-template-by-using-tower-api/26101/11 "2017-11-29T13:13:44Z")

</div>

This was put on the agenda for the saved launch-time configuration feature

[https://github.com/ansible/awx/issues/169](https://github.com/ansible/awx/issues/169)

It has been implemented in a branch of mine, I’m just trying to wrap this up as quickly as I can.
