Linking Workflow Nodes via API call

,

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.

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?

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

1 Like

I’ll give both these ideas a run!

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!