Retrieving information about workflows via REST APID
We are trying to do a YouTrack state machine workflow visualization.
For that, we can retrieve first all workflows via:
/api/admin/workflows?$top=-1&fields=id,name,rules(id,name,readOnly,title,type),title,updated,usages(isBroken,project(id,name,shortName))&query=language:JS
The filter the rules that have type == “StateMachine” and then retrieve their definitions like:
/api/admin/workflows/$workflowId/rules/$ruleId?fields=id,name,readOnly,script,title,type&query=language:JS,system:null
and then inspect the “script” attribute of the returned objects.
However, the problem is that when the state machine inlcudeds another state machine defined in a different file, like this:
var submachine = require('custom_workflows/submachine');
these rules are included as MiscellaneousObject and there is no obvious way (short of inspecting the script) how to find them via the REST API. Is there some attribute that can be retrieved via API that will list me all rules referenced from one rule?
Also, the official documentation on REST API for workflow information retrieval is missing (or I am not able to find it), where it is, please?
Please sign in to leave a comment.
Hello,
I'm Lena from the YouTrack Team.
First, I wish to highlight that you are using the private API, which may stop functioning at any moment without prior notification. Please keep in mind that you are using it at your own risk.
I'm afraid we do not offer any options for obtaining the workflow code using the REST API. As the mentioned API is private, we do not publish any endpoints related to retrieving the workflow code, nor do we have such plans for the future.
If you wish to build a state machine using the visual blocks, please use our visual constructor as described here: https://www.jetbrains.com/help/youtrack/cloud/workflow-constructor-state-machines.html