It's all about the answers!

Ask a question

Rest API Curl to query and create workitem - RTC

Joseph Simon Arokiaraj (21414745) | asked Nov 26 '14, 1:33 p.m.

I have tried to view all the workitems on a project using RestAPi and Curl and it doesn't return anything.If I tried the same URL on the browser, its giving me the information in XML format.


curl -k -b C:\CLM\cookies.txt https://server:9443/ccm/oslc/ contexts/_ M9gxUnC3EeSxPfxc8QYuYQ/ workitems


Also tried to create a workitem using Curl.Is there any easy way to get the xml request template for different types of workitems? if I get the template, I can easily use the template to populate the values.


Could anyone please help me on this?




sam detweiler commented Nov 26 '14, 2:44 p.m.

you must logon first.
here is one of my starter scripts

set COOKIES=.\cookies.txt

set USER=xxxx
set PASSWORD=yyyy
set HOST=https://localhost:9743

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

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

curl -k -L -b %COOKIES% "%host%/ccm/oslc/workitems/catalog

Joseph Simon Arokiaraj commented Nov 26 '14, 5:43 p.m. | edited Nov 26 '14, 8:31 p.m.

Hi Sam,

I have got the URI "curl -k -b C:\CLM\cookies.txt https://server:9443/ccm/oslc/ contexts/_ M9gxUnC3EeSxPfxc8QYuYQ/workitems" by invoking curl -k -L -b %COOKIES% "%host%/ccm/oslc/workitems/catalog

No idea why it is not returning all the workitems. Authenication was successful for me.



One answer

permanent link
sam detweiler (12.5k6189201) | answered Nov 26 '14, 9:55 p.m.
I had to add the accept header, same batch file as before

I did catalog to find the request for projects,

then executed that to get the service for workitems on that project
curl -k -L -b %COOKIES% %host%/ccm/oslc/contexts/_GYeCsFT4EeKDJbr7x3deog/workitems/services.xml

then called the service for workitems, on that project
curl -k -L -b %COOKIES% -H "Accept: application/xml" %host%/ccm/oslc/contexts/_GYeCsFT4EeKDJbr7x3deog/workitems

Your answer

Register or to post your answer.