It's all about the answers!

Ask a question

400 error when using REST / PATCH to change a workitem state


Melinda Minch (112) | asked Dec 23 '20, 1:37 p.m.
edited Dec 23 '20, 3:49 p.m.
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.

Comments
Ralph Schoon commented Feb 17 '21, 7:02 a.m. | edited Feb 17 '21, 7:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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. 


The request result body should contain more text.
 

Preconditions, follow up actions and permissions can be different on both systems. the process might be customized. 

The Content-Type looks suspicious, not sure.

One answer



permanent link
Melinda Minch (112) | answered Feb 17 '21, 10:46 a.m.
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
Ralph Schoon commented Feb 17 '21, 11:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The REST APIs support POST, PUT, GET, DELETE for CRUD. Not sure if PATCH is supported.


Melinda Minch commented Feb 17 '21, 11:08 a.m.
PATCH does seem to be supported to update workitem attributes (like title), without having to post the entire workitem and all its data:


Ralph Schoon commented Feb 17 '21, 11:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Ah, forgot about that. 


Ralph Schoon commented Mar 10 '22, 9:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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/ 

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.