It's all about the answers!

Ask a question

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

Melinda Minch (111) | 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": "" } }'

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

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.

Ralph Schoon commented Feb 17 '21, 7:02 a.m. | edited 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. 

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 (111) | 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.

Ralph Schoon commented Feb 17 '21, 11:02 a.m.

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.

Ah, forgot about that. 

Your answer

Register or to post your answer.