# Linking Workflow Nodes via API call

**URL:** <https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462>\
**Category:** Get Help\
**Tags:** api, awx\
**Created:** [January 24, 2024, 5:07pm UTC](https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462 "2024-01-24T17:07:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin\_codey](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kevin\_codey](https://forum.ansible.com/u/kevin_codey)\
**Post date:** [January 24, 2024, 5:07pm UTC](https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462/1 "2024-01-24T17:07:07Z")

</div>

I can create my workflow\_job\_template and a pair of workflow\_job\_template\_nodes via API calls, but I cannot make the second node a success\_node of the first.

I am POSTing to: /api/v2/workflow\_job\_template\_nodes/

First, I POST:  
{  
“type”: “workflow\_job\_template\_node”,  
“workflow\_job\_template”: 200,  
“unified\_job\_template”: 196,  
“success\_nodes”: ,  
“failure\_nodes”: ,  
“always\_nodes”: ,  
“all\_parents\_must\_converge”: false,  
“identifier”: “node2\_success”  
}

201 created, and I obtain the ID of the node as 15. Then I POST:  
{  
“type”: “workflow\_job\_template\_node”,  
“workflow\_job\_template”: 200,  
“unified\_job\_template”: 195,  
“success\_nodes”: [  
15  
],  
“failure\_nodes”: ,  
“always\_nodes”: ,  
“all\_parents\_must\_converge”: false,  
“identifier”: “node1\_always”  
}

Again, 201 Created and the new ID is 16. The two nodes are both “always” nodes linked directly to the Start button. I can subsequently link them in the visualizer just fine. Any attempt to repost the data gives me an “already exists” error, even when I supply the ID = 16.

I’m thinking there has to be some simple way to link these and I’m just missing it.

---

<div class="post-metadata">

**Author:** ![kevin\_codey](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kevin\_codey](https://forum.ansible.com/u/kevin_codey)\
**Post date:** [January 25, 2024, 3:34pm UTC](https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462/2 "2024-01-25T15:34:55Z")

</div>

Going to /api/v2/workflow\_job\_template\_nodes/ and “Options” gives me POST as an option, with success\_nodes\_\_search as a .related\_search\_fields option. Has anyone ever used that?

---

<div class="post-metadata">

**Author:** ![fosterseth](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/fosterseth/32/101_2.png) [@fosterseth](https://forum.ansible.com/u/fosterseth)\
**Post date:** [January 26, 2024, 6:18pm UTC](https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462/3 "2024-01-26T18:18:25Z")

</div>

One tip is to do it via the UI with the browser network debug tools open to see how the UI POSTS to the API.

I believe you need POST the `{"id": 15}` to the  
`api/v2/workflow_job_template_nodes/{id}/success_nodes/`  
endpoint

instead of posting to “success\_nodes” field on the node

Let me know if that helps.

Seth

---

<div class="post-metadata">

**Author:** ![kevin\_codey](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kevin\_codey](https://forum.ansible.com/u/kevin_codey)\
**Post date:** [January 26, 2024, 6:47pm UTC](https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462/4 "2024-01-26T18:47:32Z")

</div>

I’ll give both these ideas a run!

---

<div class="post-metadata">

**Author:** ![kevin\_codey](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kevin\_codey](https://forum.ansible.com/u/kevin_codey)\
**Post date:** [January 26, 2024, 7:14pm UTC](https://forum.ansible.com/t/linking-workflow-nodes-via-api-call/3462/5 "2024-01-26T19:14:27Z")

</div>

Bingo. Thank you.

Create the workflow then create the Workflow Nodes related to the Job\_Template then get the Workflow Node ID for X and relate to the subsequent Workflow Node ID in:  
/api/v2/workflow\_job\_template\_nodes/X/success\_nodes/

I was failing because I was trying to relate Job Template IDs, instead of Workflow Node IDs.

Thank you!
