It's all about the answers!

Ask a question

OSLC/REST API: How to change the state AND resolution of a work item?


1
1
Fabian Zaiser (235) | asked Sep 02 '16, 7:12 a.m.
edited Sep 06 '16, 5:38 a.m.
I want to change the state of a work item via the OSLC or Reportable REST API and I succeeded in doing this in most cases using the method described here: https://jazz.net/forum/answer_link/99991/. It basically works by POSTing to the work item URL appended with "?_action=[desired action]".

However this doesn't work for the action "Resolve" because it needs an extra field describing the Resolution (like "Invalid", "Fixed" etc.). I found that the list of possible resolutions is under the URL ...oslc/workflows/[Project Area UUID]/resolutions/com.ibm.team.workitem.defectWorkflow/. But how can I pass the resolution code to RTC, in addition to the "Resolve" action?

Additional information: If I try to change the state by the "Resolve" action, it fails with the message
{"oslc:message":"'Save Work Item' failed. Preconditions have not been met: The 'Root Cause Description' attribute needs to be set (work item 114391).","oslc:statusCode":403,"prefixes":{"oslc":"http://open-services.net/ns/core#"}}

Accepted answer


permanent link
Lawrence Smith (3764) | answered Sep 09 '16, 12:45 p.m.
JAZZ DEVELOPER
Hello... I haven't tried this but it looks like you need to include the "Root Cause Description" and any other required attributes with the save. The Resolution is passed in as the attribute internalResolution.

http://open-services.net/bin/view/Main/CmRestApiV1
describes how to save.

Assuming the root cause description is called rootCauseDescription, the call would look something like this:

PUT {CR URI}?_action=bugzillaWorkflow.action.resolve&oslc_cm.properties=rootCauseDescription,internalResolution
Content:
<oslc_cm:ChangeRequest>
  <rootCauseDescription>Something broke.</rootCauseDescription>
  <internalResolution>5</internalResolution>
</oslc_cm:ChangeRequest>  

You will need to play around with this for the right content.
Fabian Zaiser selected this answer as the correct answer

Comments
Fabian Zaiser commented Sep 12 '16, 7:45 a.m.

Thanks for your answer! I tinkered with it a bit and I could get it to work like this (written done for other people having this problem):

Calling the attribute "internalResolution" did NOT work for me, it has to be called "rtc_cm:resolution".

Send "text/json" (not "application/json", for some reason) as Content-Type and Accept header.

Send the following content:
{
  "rtc_cm:resolution": "com.ibm.team.workitem.defectWorkflow.resolution.r9"
}

where "com.ibm.team.workitem.defectWorkflow.resolution.r9" is just an example of a possible resolution.

The root cause description turned out to be just one of many attributes that had to be set on resolving, which can be configured, I think.

Your answer


Register or to post your answer.