It's all about the answers!

Ask a question

Creating Workitem using OSLC 2.0


Sudipto Sarkar (631343) | asked Apr 17 '15, 2:47 a.m.
Hi,

 I need to create a workitem using oslc 2.0. I am not getting the exact format of the request body to out in the rest client. Can anyone show me an exact example of the xml that I can use?

Thanks,
Sud

Accepted answer


permanent link
Dinesh Kumar B (4.1k413) | answered Apr 17 '15, 3:08 a.m.
JAZZ DEVELOPER

From my setup where creation factory is accessible through :
<oslc:creation rdf:resource="https://clm50.ibm.com/ccm/oslc/contexts/_Er238D6VEeSMB9u6bNNYlQ/workitems/task"/>
I perform a POST on
https://clm50.ibm.com/ccm/oslc/contexts/_Er238D6VEeSMB9u6bNNYlQ/workitems/task
with content type header set to :
Content-Type : application/xml
and body :
    <?xml version="1.0" encoding="UTF-8"?>
        <oslc_cm:ChangeRequest
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:dc="http://purl.org/dc/terms/"
        xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" >

        <dc:title>Contribute To on a REST WI</dc:title>
        <dc:type rdf:resource="https://clm50.ibm.com/ccm/oslc/types/_Er238D6VEeSMB9u6bNNYlQ/task"/>
        <dc:description>To check the Contributes To on a REST created Work Item</dc:description>
        <dc:creator rdf:resource="https://clm50.ibm.com/jts/users/clmadmin"/>
    </oslc_cm:ChangeRequest>
the Task work item gets created.

Notes :
a.  look at the Resource Shape to understand the Required attributes during creation and supply them.
b.  GET a work item and use the response to construct your body.
-  remove non-required attributes and
-  supply appropriate values for other attributes

hope this helps
Sudipto Sarkar selected this answer as the correct answer

Comments
Sudipto Sarkar commented Apr 17 '15, 3:34 a.m.

Hi Dinesh,

 Cheers, I am able to create work item with this. But this syntax is for oslc 2.0 or 1.0?

Thanks again!


Dinesh Kumar B commented Apr 17 '15, 4:01 a.m. | edited Apr 17 '15, 4:02 a.m.
JAZZ DEVELOPER

glad to know that.. please accept the answer if it covered your question.

its for OSLC 2.0.. 


Sudipto Sarkar commented Apr 17 '15, 8:22 a.m.

Hi Dinesh,

 One more question, what is the tag for filed against in OSLC?



Sudipto Sarkar commented Apr 28 '15, 1:42 a.m.

Hi Dinesh,

 In this above answer, when I am creating a workitem, the description field is not set,
<dc:description>To check the Contributes To on a REST created Work Item</dc:description>
Any reason for this?

Sud


Dinesh Kumar B commented Apr 28 '15, 2:21 a.m.
JAZZ DEVELOPER

HI Sudipto,

are you using the header OSLC-Core-Version with a value 2.0?
If so, I suggest performing a GET on one of your work items which has some description content and look at the tag for description from the returned response.

modify your creation content accordingly.

as for the filed here is a link 
    https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Attributes
which has the listing of all the attributes and
for filed against it is :
     rtc_cm:filedAgainst


Sudipto Sarkar commented Apr 28 '15, 4:00 a.m.

Hi Dinesh,
Yes, I am using OSLC 2.0
 From my response, The desc field looks like:

<dcterms:description rdf:parseType="Literal"></dcterms:description>;
When I am tryin with  "dcterms", i am getting error as " field is not bound".

Sud


Leon Sun commented Jan 24 '18, 4:04 p.m. | edited Jan 24 '18, 4:05 p.m.

Have anyone used Python package rtcclient 0.6.0 on RTC with OSLC 2.0 successfully? I got "not well-formed (invalid token)" error when I tried to get work item by (for example),

myclient = RTCClient(url, username, password, ends_with_jazz=False)
wk = myclient.getWorkitem(1643428)

. The root cause appears to be the xmltodict.parse( ) can't parse the response content without error.

showing 5 of 7 show 2 more comments

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.