It's all about the answers!

Ask a question

cURL GET WI - RTC 4.0.3


Kartik Manchanda (767) | asked Feb 03 '14, 3:57 p.m.
edited Feb 04 '14, 2:37 a.m. by Krzysztof Kaźmierczyk (7.4k34694)
 Hello

I am trying to perform a GET call using cURL. Below is the script. However below does not create wi-53.xml. Need help to figure this out.

set COOKIES="C:\RTC\OSLC\cookies.txt"
set USER=xxxx
set PASSWORD=xxxx
set URL="http://ccm-host/ccm/oslc/workitems/53"
set host="http://jts-host"

curl -k -c %cookies% "%host%/jts/authenticated/identity"

curl -k -L -b %COOKIES% -c %COOKIES% -d j_username=%USER% -d j_password=%PASSWORD% "%host%/jts/authenticated/j_security_check"

curl -D - -k -b %COOKIES% -o "wi-53.xml" -H "Accept: application/x-oslc-cm-change-request+xml" %URL%

***********************************************************************************************************************************


cookies.txt :

# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

jts-host FALSE / FALSE 786297600 WASReqURL ""
jts-host FALSE / FALSE 0 LtpaToken2 A1DKJYhHcw4po2eeUP2Wx6TVy4D7FB640pIrxiN9RXHoRwz5IS67o8ggEt+Re0dG+big6xs/1hlolfsJAZgF/PUH24Tt4Ugc2dgA2rGyXb3enupjOfg6EzTmJnRsJp6CVIATvTrlo050Cf6SJvwqBDKZOl5cQAuGT5rHt0HaVq6rYIGGlz4MWK6LsLi5urTlfMXBMUuzTYPxkc2JdkpnZ24CAMYM/+KSV20rX5pq14OU6YEzqYIRbQAmnhADfPl5qoIXqDPwFNNL5e7FLTaRkIGWxU9MZnsEqJcFrLSSi1Tl/Z4eebdyakBASNphI1Y4MaB5HR4ayjFlVjT6BZ21iGFFhldhNbtJ5MTd2QxvVY7QRvCR3AHkz/f/V423AYGGptckkQpjbKhhdx4U6xNUZgKp4chYUuFyeATP3hab0+4aDStpUn0QG6W/szQq1fg4jUQy211rnJ4i0ePXE8cX0qP/UVsbByYPN9eIPosQj4N/nYc/yUppcZHdkVrhfigasp5/TwfbNSO1kbPl4Q8QmraB407OY3Th4XU1USsqGaJL4ovnvi0Tp8tjyPGi7kHTW49AcykkUVr9c8UNqa4w2OKs3AFS1s1wpd1awXRdkQLoOCLIzty5Oq38S3ELNyFBgwV/4n0INByqLog4gCVxZKrmUC1ofyqzh0xfx1bZ18KlK3Iwej8s8p5unDbx/73RryvdXlNq3q5lm8HcdZglVg==
jts-host FALSE / FALSE 0 JSESSIONID 00005zrv-9vFaCxCJnYtQqIsquM:-1
jts-host FALSE /jts/authenticated/ FALSE 0 X-com-ibm-team-foundation-auth-loop-avoidance false

Accepted answer


permanent link
Simon Washbrook (67216) | answered Feb 04 '14, 2:27 a.m.
Hi Kartik,

Try adding "?oslc_cm.properties=dc:description" to your URL to say that you want the description of the work item.
Add the verbose flag to cURL also helps to understand what is happening

This worked for me:

# Update this line with the name of server
HOST="https://<your hostname>/ccm"
USER=xxxx@yyy.zzz.com
PASSWORD=mypassword

# Comment this line when it works
VERBOSE=-v

COOKIES=./cookies.txt
rm $COOKIES
URL="$HOST/resource/itemName/com.ibm.team.workitem.WorkItem/26416"
OUTPUT="wi_26416.xml"

# Perform Form based authentication using curl
curl -k -c $COOKIES -o tmp.html "$HOST/authenticated/identity"
curl -k -L -b $COOKIES -c $COOKIES -o tmp.html -d j_username=$USER -d j_password=$PASSWORD "$HOST/authenticated/j_security_check"

# Add which bit of the work item we want to extract
URL=$URL?oslc_cm.properties=dc:description

# Get the work item in XML format
curl -D header.txt -X GET $VERBOSE -k -b $COOKIES -o $OUTPUT -H "Accept: application/x-oslc-cm-change-request+xml" $URL

Simon
Kartik Manchanda selected this answer as the correct answer

Comments
Kartik Manchanda commented Feb 04 '14, 1:17 p.m.

Thank You SImon..Finally seems to be heading in the right direction. Much appreciated. 


Kartik Manchanda commented Feb 04 '14, 1:41 p.m.

Another QQ : In order to get a state of a particular WI, it this correct?

 set URL=%URL%?oslc_cm.properties=rtc_cm:state

One other answer



permanent link
Simon Washbrook (67216) | answered Feb 05 '14, 2:30 a.m.
Hi Kartik,
If you use

%URL%?oslc_cm.properties=rtc_cm:state

Then you will get
<?xml version="1.0" encoding="UTF-8"?>
<oslc_cm:ChangeRequest xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://$HOST/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/26416">
<rtc_cm:state rdf:resource="https://$HOST/ccm/oslc/workflows/_Zu67at-uEeCFsdAYmU6XKQ/states/bugzillaWorkflow/3"/>
</oslc_cm:ChangeRequest>

So the state is enclosed in a <oslc_cm:ChangeRequest> tag and the value is a reference to the resource that describes the state. If you follow the link to the resource then you will get the information about the id and a title that is human readable. Like this:

<rtc_cm:Status rdf:about="https://$HOST/ccm/oslc/workflows/_Zu67at-uEeCFsdAYmU6XKQ/states/bugzillaWorkflow/3">
<dc:identifier>3</dc:identifier>
<dc:title>Resolved</dc:title>
<rtc_cm:iconUrl>https://$HOST/ccm/service/com.ibm.team.workitem.common.internal.model.IImageContentService/processattachment/_Zu67at-uEeCFsdAYmU6XKQ/workflow/resolve.gif</rtc_cm:iconUrl>
<rtc_cm:group>closed</rtc_cm:group>
</rtc_cm:Status>

Enjoy,
Simon

Comments
Kartik Manchanda commented Feb 07 '14, 3:20 p.m.

Simon

Could you look @ https://jazz.net/forum/questions/141514/curl-put-wi-rtc-403-state-transition
I am sure..you would have done it in past.

Once again thanks

Your answer


Register or to post your answer.