It's all about the answers!

Ask a question

REST api for changing the state of the workitem doesn't work with RTC 4.0.1


0
2
Binoy D'costa (723416) | asked Mar 27 '13, 10:26 a.m.
retagged Dec 03 '13, 4:34 p.m. by David Lafreniere (9267)
 I have a script to move workitem from "Resolved" state to "Built" state. Details below:

Curl cmd:

curl -s -k -b ~/.jazzcookies -H "If-Match:64486.etag" -H "Content-Type: application/x-oslc-cm-change-request+json" -H "Accept: application/x-oslc-cm-change-request+json" -X PUT --data-binary 64486.updated.json "https://clm-host/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/15954?_action=bugzillaWorkflow.action.a6"

Error;

{
    "oslc_cm:message": "CRJAZ0007I Unable to update the item identified by \"https:\/\/clm-host\/jazz\/service\/com.ibm.team.repository.common.internal.IItemRestService\/itemName\/com.ibm.team.workitem.WorkItem\/64486?_action=bugzillaWorkflow.action.a6\" - there is a later version of this item available.",
    "oslc_cm:status": 412


Please advise. I have some important services on halt.

Thanks,
Binoy

5 answers



link
Jorge Alberto Diaz (8311832) | answered Oct 16 '13, 12:06 p.m.
JAZZ DEVELOPER
edited Oct 23 '13, 12:25 p.m.
Hi Luis,

I have tried on my local system and I found out the following:
 - with curl I reproduce the error
 - if I use FF poster it works (including the etag parameter)

so it sounds like curl is not preserving the quotes as needed.

Update: I found the mistake in my curl call and posting the corrected version. It's  working for me on my system (v4.0.4). See the escape characters for the ETag value.

curl -k -b $COOKIES --header "Content-Type:application/json" --header "Accept:application/x-oslc-cm-change-request+json" --header "If-Match: \"<etagvalue>\""  -X PUT --data-binary "@<id>.json" <server>/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/<id>?_action=com.ibm.team.workitem.taskWorkflow.action.startWorking"

Anyway, I double-checked with FireFox Poster add-on again, and the ETag value along with the If-Match parameter are working as expected

Regards,

Jorge.

Comments
Jorge Alberto Diaz commented Oct 16 '13, 12:16 p.m.
JAZZ DEVELOPER
Sorry, worth mentioning I tried this with RTC 4.0.4

Luis Bazo commented Oct 17 '13, 4:56 a.m.
JAZZ DEVELOPER
Thanks for your suggestion but unfortunately we are running on windows and we don't have sed.

Luis Bazo commented Oct 17 '13, 7:55 a.m.
JAZZ DEVELOPER
Hi!!

I made it work by removing the "If-Match" header from the PUT request.

For reference of others with same issue this is my log of steps I followed to change WI state (I've used JSON instead of XML)

curl -k -c cookies.txt "https://jts-test:9443/jts/authenticated/identity"

curl -k -L -b cookies.txt -c cookies.txt -d j_username=612979 -d j_password=612979 https://jts-test:9443/jts/authenticated/j_security_check

curl -o 151.json -k -b cookies.txt "https://jts-test:9443/ccm/oslc/workitems/151.json" -H "Content-Type:application/x-oslc-cm-change-request+json"

curl -k -v -b cookies.txt "https://jts-test:9443/ccm/oslc/workitems/151.json" --header "Content-Type:application/x-oslc-cm-change-request+json" --header "Accept:application/x-oslc-cm-change-request+json" -X PUT --data-binary @151.json "https://jts-test:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/151?_action=com.ibm.team.workitem.taskWorkflow.action.startWorking"

link
Christopher Ricci (9815) | answered Mar 27 '13, 7:49 p.m.
The problem appears to be related to the way you are quoting the If-Match header.  Your command should look like this (notice the single quotes:

curl -s -k -b ~/.jazzcookies -H 'If-Match:"64486.etag"' -H "Content-Type: application/x-oslc-cm-change-request+json" -H "Accept: application/x-oslc-cm-change-request+json" -X PUT --data-binary 64486.updated.json "https://clm-host/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/15954?_action=bugzillaWorkflow.action.a6"

Comments
Binoy D'costa commented Mar 28 '13, 1:34 p.m.
Tried with single quotes as you suggested, still doesn't work. Getting the same oslc_cm:status: 412 message.

Please help.

link
Binoy D'costa (723416) | answered Apr 05 '13, 10:47 a.m.
edited Apr 05 '13, 10:48 a.m.
The work around i have is to remove the "If-Match" header. Somehow JTS 4.0.1 server does not process this as it used to with 3.0.1

link
Michele Pegoraro (1.5k94475) | answered Apr 29 '13, 6:56 a.m.
 I'm facing the same problem but I don't think that removing the header is a workaround. Any news on this? How can the If-Match header be used in version 4?

Thanks,
Michele.

Comments
Binoy D'costa commented May 07 '13, 11:56 a.m.
I don't have any update. Unfortunately, RTC Rest api are not supported by IBM and I haven't found any useful information in the forums.

link
Luis Bazo (683818) | answered Oct 16 '13, 10:09 a.m.
JAZZ DEVELOPER

Hi,

Facing same problem any update?

C:\IBMSW\curl-7.32.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32\curl-7.32.0-rtmp
-ssh2-ssl-sspi-zlib-idn-static-bin-w32>curl -D - -k -b cookies.txt -H "Content-T
ype:application/x-oslc-cm-change-request+xml" -H "Accept:application/x-oslc-cm-c
hange-request+xml" -X PUT --data-binary @151.xml "https://jts-test:9443/ccm/reso
urce/itemName/com.ibm.team.workitem.WorkItem/151?_action=com.ibm.team.workitem.d
efectWorkflow.action.startWorking"
HTTP/1.1 100 Continue
Content-Length: 0
Date: Wed, 16 Oct 2013 15:54:40 GMT

HTTP/1.1 409 Conflict
Date: Wed, 16 Oct 2013 15:54:40 GMT
X-Powered-By: Servlet/3.0
Cache-Control: private, max-age=0, must-revalidate
Expires: Wed, 16 Oct 2013 15:54:40 GMT
Vary: Accept
Content-Type: text/xml;charset=UTF-8
Content-Language: en-US
Content-Length: 213
Connection: Close

<oslc_cm:error xmlns:oslc_cm="&lt;a href=" http:="" open"="">http://open-
services.net/xmlns/cm/1.0/">;
<oslc_cm:status>409</oslc_cm:status>
<oslc_cm:message>Illegal value: </oslc_cm:message>
</oslc_cm:error>
C:\IBMSW\curl-7.32.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32\curl-7.32.0-rtmp
-ssh2-ssl-sspi-zlib-idn-static-bin-w32>curl -D - -k -b cookies.txt -H "If-Match:
 090cf19a-d29d-361e-a751-42f133086e1b" -H "Content-Type:application/x-oslc-cm-ch
ange-request+xml" -H "Accept:application/x-oslc-cm-change-request+xml" -X PUT --
data-binary @151.xml "https://jts-test:9443/ccm/resource/itemName/com.ibm.team.w
orkitem.WorkItem/151?_action=com.ibm.team.workitem.defectWorkflow.action.startWo
rking"
HTTP/1.1 100 Continue
Content-Length: 0
Date: Wed, 16 Oct 2013 15:58:20 GMT

HTTP/1.1 412 Precondition Failed
Date: Wed, 16 Oct 2013 15:58:20 GMT
X-Powered-By: Servlet/3.0
Cache-Control: private, max-age=0, must-revalidate
Expires: Wed, 16 Oct 2013 15:58:20 GMT
Vary: Accept
Content-Type: text/xml;charset=UTF-8
Content-Language: en-US
Content-Length: 501
Connection: Close

<oslc_cm:error xmlns:oslc_cm="&lt;a href=" http:="" open"="">http://open-
services.net/xmlns/cm/1.0/">;
<oslc_cm:status>412</oslc_cm:status>
<oslc_cm:message>CRJAZ0007I Unable to update the item identified by "https://jts
-test:9443/ccm/service/com.ibm.team.repository.common.internal.IItemRestService/
itemName/com.ibm.team.workitem.WorkItem/151?_action=com.ibm.team.workitem.defect
Workflow.action.startWorking" - there is a later version of this item available.
</oslc_cm:message>
</oslc_cm:error>
C:\IBMSW\curl-7.32.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32\curl-7.32.0-rtmp
-ssh2-ssl-sspi-zlib-idn-static-bin-w32>

Your answer


Register or to post your answer.