It's all about the answers!

Ask a question

Unable to fetch the custom attribute prefix tag of artifect type defect


Rahul Singh Bhadauriya (2821720) | asked Mar 10 '14, 6:44 a.m.
edited Mar 10 '14, 9:19 a.m. by Paul Slauenwhite (8.4k12)
RTC Version 4.0.3

I have created custom attribute in the RTC of WorkItem type Defect.
I have marked these attributes as a mandatory . I want to create defects in RTC using my java client.

Questions:
1. How to fetch the attribute prefix Tag to create the XML change request .
i.e 
<rtc_ext:Test1 rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</rtc_ext:Test1>
here, Test1 is a mandatory attribute of type integer added in Workitem type Defect.
rtc_ext:Test1 Tag is required to create XML Change Request to create defects in RTC which i am unable to fetch.

2. what about system defined attributes , how to fetch the prefix tags for those?
i.e.

<
rtc_cm:filedAgainst rdf:resource="https://localhost:9443/ccm/resource/itemOid/com.ibm.team.workitem.Category/_BzHUxJiHEeO_g7YLV-uN1A"/>

here, I need to fetch the Tag
rtc_cm:filedAgainst.
I am able to fetch the internal name of the attribute from the resource shape. 

Thanks
Rahul

One answer



permanent link
Donald Nong (14.5k414) | answered Mar 10 '14, 11:13 p.m.
It sounds strange that you cannot find the information in the resource shape. I suppose you get confused with what the "prefix" is - it is simply a namespace declaration, or a "shorthand" if you like. Here is something you can do, and hopefully get what you want.
1. Follow the usual chain of discovery till you get the resource shape of the defect. In the shape content, search the custom attribute name and you should get something like this
<oslc:propertyDefinition rdf:resource="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/customAttribute"/>
Here the name space is http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/ and you need to declare this before you can use it in a request body.
2. Depending on the name of your choice, you can declare the namespace as below
xmlns:rtc_ext="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/"
In this case, you can use <rtc_ext:customAttribute> to refer to your custom attribute in your request body.
3. If you want to get a sample of the RDF/XML presentation of a Defect work item, simply do a GET request of an existing Defect work item with the custom attribute. At the top part of the response, you should observe the same line as quoted above. All the attributes with the "rtc_ext" prefix are custom attributes. The other attributes have different prefix depending on in which namespace they are defined.
I don't know how you do the "fetch", but to get consistent result, always use HTTP headers "Accept: application/rdf+xml" and "OSLC-Core-Version: 2.0" with your request.

Comments
Rahul Singh Bhadauriya commented Mar 11 '14, 10:19 a.m.

Thanks Donald for your quick response. Now i am able to identify the attribute prefix based on the name spaces defined for them.

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.