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 (9532437) | asked Mar 27 '13, 10:26 a.m.
retagged Dec 03 '13, 4:34 p.m. by David Lafreniere (4.8k7)
 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

6 answers



permanent link
Jorge Diaz (8664434) | 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 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"


permanent 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.


permanent link
Binoy D'costa (9532437) | 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

permanent link
Michele Pegoraro (1.8k14118103) | 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.


permanent link
Luis Bazo (6832019) | 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

<?xml version="1.0" encoding="UTF-8"?><oslc_cm:error xmlns:oslc_cm="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

<?xml version="1.0" encoding="UTF-8"?><oslc_cm:error xmlns:oslc_cm="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>


permanent link
Liney Reis (139) | answered Jul 29 '16, 5:26 p.m.
Hello,

I´m trying to do use curl to change the state in 6.02 version, but getting error 500:

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

curl -k -v -b %COOKIES% "https://server:9443/ccm/oslc/workitems/1503706.json" --header "Content-Type:application/x-oslc-cm-change-request+json" --header "Accept:application/x-oslc-cm-change-request+json" -X PUT --data-binary @1503706.json "https://server:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/1503706?_action=change_workflow.action.a2"
--------------------------

result:

> Content-Type:application/x-oslc-cm-change-request+json
> Accept:application/x-oslc-cm-change-request+json
> Content-Length: 13805
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 100 Continue
< Content-Length: 0
< Date: Fri, 29 Jul 2016 21:13:05 GMT
< HTTP/1.1 500 Internal Server Error
< Date: Fri, 29 Jul 2016 21:13:05 GMT
< X-Powered-By: Servlet/3.0
< Cache-Control: private, max-age=0, must-revalidate
< Expires: Fri, 29 Jul 2016 21:13:05 GMT
< Vary: Accept
< Content-Type: application/x-oslc-cm-change-request+json;charset=UTF-8
< Content-Language: pt-BR
< Connection: close
< Transfer-Encoding: chunked
<
{
    "oslc_cm:message": null,
    "oslc_cm:status": 500

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.