400 error when using REST / PATCH to change a workitem state
Hi all,
I'm using REST to try and change the state of a work item in Rational Team Concert, like this:
curl -k -X PATCH -b ~/cookie-test.txt -H "Content-Type: application/x-oslc-cm-change-request+json" -H "Accept: application/json" -d '{"rtc_cm:state": {"rdf:resource": "https://rtc.astsnet.com/ccm/oslc/workflows/_4d-C4A_hEei4Y9x1-0JhoA/states/com.ibm.team.workitem.defectWorkflow/com.ibm.team.workitem.defectWorkflow.state.s34" } }' https://rtc.astsnet.com/ccm/oslc/workitems/313172?_action=com.ibm.team.workitem.defectWorkflow.action.a43
In my test environment, this works fine, but in Production, it returns a 400 error. There isn't anything revealing in the logs.
Both test and production are running 6.0.6.1.
I'm not sure what's going on! I tried filling in the estimate fields and leaving them blank, as well as sending `rtc_cm:resolved` along with my state.
Are there configuration or other differences I should look for in order to figure out what might make this work in Production?
This only seems to happen with PATCH operations.
[Edited to remove log entry that now seems like it is probably unrelated]
Any pointers you have or things I might try would be helpful. Thank you.
One answer
I'm glad I got a couple replies, because I have an update and didn't remember to post it here.
I am still mystified about the difference between the test and the production environments that I'm seeing, but I worked around this by using 'PUT' instead of 'PATCH' for the state transition. It seems that actions work better with 'PUT', and it did not overwrite any workitem attributes.
Comments
The REST APIs support POST, PUT, GET, DELETE for CRUD. Not sure if PATCH is supported.
PATCH does seem to be supported to update workitem attributes (like title), without having to post the entire workitem and all its data:
Ah, forgot about that.
Follow up, as far as I can tell PATCH is not supported - in some calls I get a not implemented error. To do partial update, use the oslc.properties query parameter. See my findings in https://rsjazz.wordpress.com/2022/02/02/ewm-work-item-oslc-cm-api/
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 17 '21, 7:03 a.m.Are you able to do the state change manually? try using RESTCLIENT in Firefox or Postman. Switch off auto redirect and look if the error messages are better.