It's all about the answers!

Ask a question

Is there any way to discover the valid actions for a state via the REST API?

Robert Heinemeyer (33910) | asked Jan 02 '15, 2:50 p.m.
The title sums it up.  I've been able to divine the means to discover actions leading to a state (https://[server]/ccm/oslc/workflows/[Project UUID]/actions/[workflow]) but I am at a loss on how to determine which actions can be performed from a given state.

The most helpful answer I was able to find wasn't able to answer how it can be done via the REST API.  Is it not implemented?

(For reference, this is using RTC v4.0.6) 

One answer

permanent link
Andre Carlos Antunes de Oliveira (4024) | answered Aug 14 '16, 1:47 a.m.
I think I've find a way to determine which actions can be performed from a given state using RTC's reportable REST API and a "http get" to a resource (I don't know if it can be called a REST or an OSLC call).
I did a test using RTC 5.0.2 and MSXML in an MS-Excel module and, apparently, it worked.
If it work to you too, please, let me know.

- First, we get the contentId of the process configuration using Reportable REST API .
- For example, to the 'JUnit Project' sample project area, we call "https://<server-name>:9443/ccm/rpt/repository/generic?fields=generic/[name='JUnit Project']/processData[key='']/value/contentId". 
- Let's say that the result was "_R7wEwPn7EeWpjbQPCeBbyw"
- Then, we get the process configuration doing a "http get" in "https://<server-name>/9443/ccm/resource/content/_R7wEwPn7EeWpjbQPCeBbyw", passing JSESSIONID in "X-Jazz-CSRF-Prevent" request header and "application/xml" in "Accept" request header.
- If  we are looking for all possible actions from a state of the task workitem type, and ...
- If we already know the workflow id, we can look for the "workflowDefinition" tag with id attribute is the desired workflow. For example, "".
- If we don't know the workflow id, we can look for <configuration-data>/<workItemCategoryBinding workItemCategoryId=""> and get the "workflowId" attribute there.
- From "workflowDefinition", I think that the "workflow" child has "state" children, who has "action" childs that can be performed by each state.
- Remember: to save a workitem, we need to supply the required attributes, has the correct role, and do all that is explained in, topic "Resource Operations".
- To know the required attributes, we look in the process configuration for <behavior>/<role id='roleid'>/<operation>/<precondition>/<properties workItemTypeCategory='workItemTypeCategory'>/<property>  tags and get the "id" attribute.
- If we don't know what means that "id" attribute in terms of OSLC tags, I think that we can do a Reportable Rest http call to discovery its <displayName> and then look this in <dcterms:title> of the resource shape properties of that given workitem type. 
- For example, let's say that the required attribute id was "", so, we can look for the "summary" attribute, doing this by calling https://<server-name>:9443/ccm/rpt/repository/generic?fields=generic/[projectArea/name='JUnit Project' and identifier=summary]/displayName.
- To get the resource shape, see the instructions in

- I apologize if wrote too much, but, like you, I find no other means, answers, articles, documentation or tip to know all possible actions for a given state using Reportable REST Api and/or OSLC, and this drives me crazy to find an answer.

Best Regards

Your answer

Register or to post your answer.