It's all about the answers!

Ask a question

Change WorkItem State via REST


0
1
Erik Vonderheid (461) | asked Mar 10 '10, 6:01 a.m.
Hi,

I'm using RTC 2.0.0.2 Standard Edition and I'm trying to change the state of a WorkItem via REST.

REST URL:

https://lap-ibm-853.psad.de:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/28

JSON:

{"dc:identifier":28,
"rtc_cm:state":{
"rdf:resource":
"https:\/\/LAP-IBM-853.PSAD.de:9443\
/jazz\/oslc\/workflows\/_Wp0-gCeREd-nSqqeCWspMA\
/states\/bugzillaWorkflow\/5"
},
...


I'm using a org.apache.http.client.methods.HttpPut against the URL with the JSON as org.apache.http.entity.StringEntity.

The response is a 400: Bad Request.

All I want to do is change the state from
resolved

https://LAP-IBM-853.PSAD.de:9443/jazz/oslc/workflows/
_Wp0-gCeREd-nSqqeCWspMA/states/bugzillaWorkflow/3

to closed

https://LAP-IBM-853.PSAD.de:9443/jazz/oslc/workflows/
_Wp0-gCeREd-nSqqeCWspMA/states/bugzillaWorkflow/5

Accepted answer


19 other answers



permanent link
Erik Jägervall (73710) | answered May 28 '12, 4:32 a.m.
I can partially answer my self - first doing a GET with Accept: application/json and then taking the received data and adding that as body of type Content-Type:application/json when doing the POST solved the case, but the question remains, it is possible to change the state without first doing a GET or without including all data from the GET?

br erik


Hi!



But what do I need to include in form of body and content-header? Do I need to make a GET-request first to get some data or should the simple PUT-request above be sufficient? (It identifies the work item and the action I want to perform)

br Erik

permanent link
Erik Jägervall (73710) | answered May 28 '12, 4:22 a.m.
Hi!

I am also struggling with getting this to work (using RTC 3.0)

As I understand it a PUT request like below should change my defect from "New" to "In Progress"

https://localhost:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/1824?_action=com.ibm.team.defectWorkflow.action.startWorking

But what do I need to include in form of body and content-header? Do I need to make a GET-request first to get some data or should the simple PUT-request above be sufficient? (It identifies the work item and the action I want to perform)

br Erik

permanent link
Michael Lee (622) | answered Mar 09 '12, 10:30 a.m.
Hi, I've trying to change the workitem status, but isn't work

I'm doing this with Poster add-on for Firefox

my first step was doing a GET in a workitem like this:

https://jazz-server:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/519?oslc_cm.properties=rtc_cm:state

with this body response:

http://img40.imageshack.us/img40/4959/gett.png

after that i made a PUT like this:

https://jazz-server:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/519?_action=bugzillaWorkflow.action.startWorking

with this body to send:

http://img190.imageshack.us/img190/462/puti.png



But didn't work. What I'm doing wrong?




Hi,

I just found the solution to the problem. In the action parameter at the end of the URL, the action should not have contained com.ibm.team.workitem and should just have been bugzillaWorkflow.action.close. This allowed the state to be changed from resolved to closed.

The final URL is:

https://dptlfccm01:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/220?_action=bugzillaWorkflow.action.close

permanent link
Paulo Anjos (611) | answered Sep 14 '10, 1:49 p.m.
Hi, I'm new in RTC development and I'm trying to do an integration between RTC and a java application running in a Websphere Application Server, I saw a lot of documents explaining how to manipulate workitems using curl, but I'm using java and Apache HTTPClient, I could do a login, but when a try to do a GET request to get a Json representation of a work Item, I get only the page "loading" as a result, does anyone had already done something like that? I know it should be very easy to do, but I couldn't find nothing that can help me, I will post the part of code that I'm doing the request.

Tks.

GetMethod getMethod = new GetMethod("https://localhost:9443/jazz/resource/itemOid/com.ibm.team.workitem.WorkItem/_TL6WwLaXEd-U-rkh_zo9Sg?oslc_cm.properties=dc:title,rtc_cm:comments,rtc_cm:com.ibm.team.workitem.linktype.relatedworkitem.related");

getMethod.addRequestHeader(new Header("Accept","application/x-oslc-cm-change-request+json"));
try {
httpclient.executeMethod(getMethod);
} catch (HttpException httpe) {
System.out.println(httpe.getMessage());
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
}
String responseBody = getMethod.getResponseBodyAsString();

System.out.println("The page start here: ");

System.out.println(responseBody);

getMethod.releaseConnection();

permanent link
Patrick Streule (4.9k21) | answered Apr 30 '10, 1:19 p.m.
JAZZ DEVELOPER
We are trying to update Workitem state in RTC via OSLC Client with
"https://localhost:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/48?_action=com.ibm.team.workitem.bugzillaWorkflow.action.close
", but it is not working. We tried copying this URL to browser
even that is not working. Please throw some light on this.

Updating a work item requires a PUT or PATCH HTTP operation. Entering
the above URL in a browser is a GET operation, which will not modify the
state of the work item.

Please also check Pat McCarthy's steps from the previous post to track
down the problem.

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Pat McCarthy (12152) | answered Apr 29 '10, 9:01 a.m.
JAZZ DEVELOPER
Have you validated that you can open the WI directly in the browser or RTC Client UI and can get the close action on the drop down? This would ensure that the current state of the WI can accept a close action.

Have you validated that your process has an action with that id?

Open the project area definition, go to the Process Configuration Source tab, and do a find on "com.ibm.team.workitem.bugzillaWorkflow.action.close". This would ensure that your action id is known to the process.

Did you try the poster add on tool (firefox add on)?

We are trying to update Workitem state in RTC via OSLC Client with "https://localhost:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/48?_action=com.ibm.team.workitem.bugzillaWorkflow.action.close ", but it is not working. We tried copying this URL to browser even that is not working. Please throw some light on this.
Thanks,
Goutham

Comments
Tony Eastwood commented Jul 12 '12, 11:59 a.m.

Pat, How do I get the possible values from the 'Process Configuration Source tab' programatically via REST?


permanent link
Pradeep Dakua (6) | answered Apr 29 '10, 8:22 a.m.
We are trying to update Workitem state in RTC via OSLC Client with "https://localhost:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/48?_action=com.ibm.team.workitem.bugzillaWorkflow.action.close ", but it is not working. We tried copying this URL to browser even that is not working. Please throw some light on this.
Thanks,
Goutham

permanent link
Patrick Streule (4.9k21) | answered Mar 24 '10, 11:18 a.m.
JAZZ DEVELOPER
Net question - is this form of a WI ref acceptable?
/resource/itemOid/com.ibm.team.workitem.WorkItem/_aHeWkAYSEd-eNvZmgqmttg


vs :
/resource/itemName/com.ibm.team.workitem.WorkItem/47

Yes, that's perfectly ok.

The UUID ref style works, I just wonder if it is and appropriate form
for use with the WI REST API.

As a rule of thumb, any URL you find in a representation (e.g. the query
result) can be used.

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Pat McCarthy (12152) | answered Mar 24 '10, 10:38 a.m.
JAZZ DEVELOPER
Question on the URL used for WI REST interaction. I've found/read a few posts; adding my Q to this one....

I see examples like:
https://dptlfccm01:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/220?_action=com.ibm.team.workitem.bugzillaWorkflow.action.startWorking

Where the key bit for my Q is:
/resource/itemName/com.ibm.team.workitem.WorkItem/220

I'm starting from a different entry point. My code:
1 - finds the right query to run using this url:
https://corkt40:9443/jazz/oslc/queries?oslc_cm.properties=rtc_cm:projectArea{dc:title},dc:title,rtc_cm:results

2- I then search that response to get my query to run; getting a ref like this:
https://192.168.1.172:9443/jazz/oslc/queries/_Tbg04QYSEd-GeMSCO5mv1Q/rtc_cm:results

3- I use that URL to get WIs, scan the query result and pick one - getting a ref like this from the:
https://192.168.1.172:9443/jazz/resource/itemOid/com.ibm.team.workitem.WorkItem/_aHeWkAYSEd-eNvZmgqmttg

4 - I then use that in my state update - like this:
https://192.168.1.172:9443/jazz/resource/itemOid/com.ibm.team.workitem.WorkItem/_aHeWkAYSEd-eNvZmgqmttg?_action=com.ibm.team.workitem.defectWorkflow.action.startWorking


Net question - is this form of a WI ref acceptable?
/resource/itemOid/com.ibm.team.workitem.WorkItem/_aHeWkAYSEd-eNvZmgqmttg

vs :
/resource/itemName/com.ibm.team.workitem.WorkItem/47

The UUID ref style works, I just wonder if it is and appropriate form for use with the WI REST API.

permanent link
Erik Vonderheid (461) | answered Mar 17 '10, 5:42 a.m.
You can do a regular PUT of the resource as you would for changing any
attribute, but include the workflow action as a URL parameter:

....com.ibm.team.workitem.WorkItem/247?_action=com.ibm.team.workitem.defectWorkflow.action.startWorking

Here's an example curl script which changes the work item's state:

COOKIES=./cookies.txt

URL=https://localhost:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/247?_action=com.ibm.team.workitem.defectWorkflow.action.startWorking

curl -D - -k -b $COOKIES -H "If-Match: $1" -H "Content-Type:
application/x-oslc-cm-change-request+xml" -H "Accept:
application/x-oslc-cm-change-request+xml" -X PUT --data-binary @247.xml $URL


--
Regards,
Patrick
Jazz Work Item Team


Thanks for your answer. However I solved my problem by adding a custom REST service.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.