How to cancel a running workflow job on Ansible Tower?

I tried to use the following API to cancel a running workflow job,

https://tower_IP/api/v2/workflow_jobs/192/cancel/

But got the below response,

{
“detail”: “Method "POST" not allowed.”
}

Also tried “DELETE”, got the same result. Using “GET”, got the status of “can_cancel” field,

{
“can_cancel”: false or true
}

So, what the correct way to cancel a running job?

Thanks.

This sounds right. You should be able to POST to the cancel endpoint with empty data. The error message you got is consistent with can_cancel being false. I would expect can_cancel to be false in the case that the workflow job had finished running.

If the workflow job is still running, it should cancel itself, propagate the cancel to any running jobs that it spawned, and no longer spawn any subsequent jobs.