It's all about the answers!

Ask a question

How to update reference types using OSLC Change Request XML format?


Tadeusz Janasiewicz (120149) | asked Nov 17 '14, 5:56 a.m.
edited Nov 17 '14, 8:39 p.m.
I would like to update Enumeration List attributes using the REST API based on XML format.

I know how to do that using the JSON format see the [1], but in case of XML format even when I try to get values of this attribute I get only the info about the reference type without the values:

Get Enumeration List values


I found an example how to add a link which is also a reference type [2], but it does not work.


I used a request like this one:

<oslc_cm:ChangeRequest xmlns:rtc_cm="https://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" xmlns:oslc_disc="http://open-services.net/xmlns/discovery/1.0/" xmlns:dc="http://purl.org/dc/terms/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:jp="https://jazz.net/xmlns/prod/jazz/presentation/1.0/" xmlns:jd="https://jazz.net/xmlns/prod/jazz/discovery/1.0/" xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:calm="https://jazz.net/xmlns/prod/jazz/calm/1.0/">
  <dc:title>Changed title</dc:title>
  <rtc_cm:related_projects_attribute oslc_cm:collref="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects/Project%202" />
</oslc_cm:ChangeRequest>

or

<oslc_cm:ChangeRequest xmlns:rtc_cm="https://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" xmlns:oslc_disc="http://open-services.net/xmlns/discovery/1.0/" xmlns:dc="http://purl.org/dc/terms/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:jp="https://jazz.net/xmlns/prod/jazz/presentation/1.0/" xmlns:jd="https://jazz.net/xmlns/prod/jazz/discovery/1.0/" xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:calm="https://jazz.net/xmlns/prod/jazz/calm/1.0/">
  <dc:title>Hello!</dc:title>
  <rtc_cm:related_projects_attribute oslc_cm:collref="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects">
    <rtc_cm:Literal rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects/Project%202"/>
  </rtc_cm:related_projects_attribute>
</oslc_cm:ChangeRequest>

and the title was changed but the enumeration values did not.

All the enums:

<?xml version="1.0" encoding="UTF-8" ?>
 <oslc_cm:Collection oslc_cm:totalCount="4">
 <rtc_cm:Literal rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects/Project%201">
<dc:identifier>
related_projects.literal.l1
</dc:identifier>
<dc:title>
Project 1
</dc:title>
<rtc_cm:iconUrl />
 </rtc_cm:Literal>
 <rtc_cm:Literal rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects/Project%202">
<dc:identifier>
related_projects.literal.l2
</dc:identifier>
<dc:title>
Project 2
</dc:title>
<rtc_cm:iconUrl />
 </rtc_cm:Literal>
 <rtc_cm:Literal rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects/Project%203">
<dc:identifier>
related_projects.literal.l3
</dc:identifier>
<dc:title>
Project 3
</dc:title>
<rtc_cm:iconUrl />
 </rtc_cm:Literal>
 <rtc_cm:Literal rdf:resource="https://localhost:9443/ccm/oslc/enumerations/_ZvMmj2DREeSnNOlM1JrDkA/enumerationList$related_projects/Project%204">
<dc:identifier>
related_projects.literal.l4
</dc:identifier>
<dc:title>
Project 4
</dc:title>
<rtc_cm:iconUrl />
 </rtc_cm:Literal>
 </oslc_cm:Collection>


[1] https://jazz.net/forum/questions/166922/how-to-use-firebug-and-poster-to-find-and-test-rest-parameters-to-change-workitemss-in-rtc
[2] https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Adding_Links_to_a_Work_Item

Comments
Donald Nong commented Nov 18 '14, 1:11 a.m.

I cannot figure out why the response looks different in my own environment. What's the RTC version that you're using?
In my test, for a enumeration list attribute, there are more than one entries in the WI GET response if more than one values are selected for the attribute. And the URI for the enumeration is complete (your one is referenced to the enumeration type, not value). Also the attribute is in the <rtc_ext> namespace given that it's a custom attribute.


Tadeusz Janasiewicz commented Nov 18 '14, 2:26 a.m. | edited Nov 18 '14, 2:27 a.m.

Hi Donald,

I am using RTC 4.0.7 and this attribute is a custom Enumeration List with 4 different values. From what I noticed only this enumeration attribute is shown as a reference to the type, maybe there is a way to change it?
Definition of this attribute:

Custome attribute, Enumeration List
Could you please share with me how looks your GET request?


Tadeusz Janasiewicz commented Nov 18 '14, 3:27 a.m.

I also tried the solution mentioned here:

https://jazz.net/forum/questions/62917/is-it-possible-to-update-a-collection-via-oslc-rest-calls

But it does not work in my case.

FYI
@dlesin @dlesin2 @betasharko

Accepted answer


permanent link
Sandeep Somavarapu (1011) | answered Nov 20 '14, 9:06 a.m.
JAZZ DEVELOPER
 Using OSLC CM v2.0 will let you easily to update - For more details refer to this article and wiki

https://jazz.net/library/article/1001
https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20
Tadeusz Janasiewicz selected this answer as the correct answer

Comments
Tadeusz Janasiewicz commented Nov 24 '14, 9:21 a.m. | edited Nov 24 '14, 9:24 a.m.

Hi Sandeep,

Thanks, in fact when I used GET Headers:

OSLC-Core-Version:2.0
Accept:application/rdf+xml
Content-Type:application/rdf+xml


I got all the attributes' values and then I was able to use this response to modify the original Work Item using PUT with additional Header entry:

If-Match: ec781968-c722-3d81-861b-27d60037cbba

Thanks!
Tad

2 other answers



permanent link
Georg Kellner (840378108) | answered Nov 17 '14, 5:59 a.m.
Maybe this article helps:

https://jazz.net/library/article/821

Comments
Tadeusz Janasiewicz commented Nov 17 '14, 8:15 p.m. | edited Nov 17 '14, 8:41 p.m.

Hi Georg,

I am not sure how Java API can help here, but thank you!


permanent link
Donald Nong (14.5k414) | answered Nov 20 '14, 6:55 p.m.
Hi Tadeusz,
I figured out why you got a different response from mine - you missed the "OSLC-Core-Version: 2.0" request header. Or did you intentionally choose OSLC 1.0?
Once you add the header, your response should look different. It should then be easy to follow the steps outlined in the article that Sandeep posted, to update the work item.

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.