It's all about the answers!

Ask a question

How to access custom attributes of a particular work item from a particualr work area of RTC via API?


Amol Wangate (158) | asked Jun 17 '19, 10:15 a.m.
edited Jun 18 '19, 1:28 a.m. by Ralph Schoon (63.1k33645)

Need to access attributes of a work item which is in RTC work area


Comments
Ralph Schoon commented Jun 18 '19, 1:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No details => No answers. QED


Amol Wangate commented Jun 18 '19, 8:45 a.m. | edited Jun 18 '19, 8:47 a.m.
Hi Ralh, I'm trying to get data from custom attributes of a work item which is in RTC. This is what I've come up with

https://xyx:8085/ccm/rpt/repository/workitem?fields=workitem/workItem[projectArea/name='Defect Management']/(id|summary|allExtensions/(displayName|displayValue))

The problem with this URi is it is returning all custom attributes, but I'm looking for a only one. so can I modify the url and add a condition like displayName='External Id' ? if so, could u please modify it for me. Thanks

Also, I want to see only work items that have the External ID attribute NOT NULL. can we achieve that also?

Ralph Schoon commented Jun 19 '19, 1:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The API you are trying to access is the reportable REST API and I am not an expert in that one, however, REST APIs usually return all available information about an artifact and it is up to you to parse the data to get the information you are interested in. 


Ralph Schoon commented Jun 19 '19, 1:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If this is indeed about the reportaable REST API, then here should be information about what you are interested in: https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI#Field_selection_and_filtering you can get there from https://jazz.net/help-dev/clm/index.jsp?topic=%2Fcom.ibm.team.reports.doc%2Ftopics%2Fr_ccm_rest_api.html


Accepted answer


permanent link
Davyd Norris (2.2k217) | answered Jun 19 '19, 2:38 a.m.
You should be able to use this:

<...>/ccm/rpt/repository/workitem?fields=workitem/workItem[projectArea/name='Defect Management']/(id|summary|allExtensions[displayName='External Id']/(displayName|displayValue))

I have found that sometimes the Reportable REST API will permit searches on fields but will not always return data for them - it may be that you get an empty field where displayValue should be. You may need to fiddle

Amol Wangate selected this answer as the correct answer

Comments
Amol Wangate commented Jun 19 '19, 8:27 a.m. | edited Jun 19 '19, 8:28 a.m.
Thanks Davyd. It worked!

Just wondering if we have similar/such API's that returns data in JSON format instead of XML. I know I can parse this XML into JSON. Just wanted to avoid extra efforts.


Davyd Norris commented Jun 19 '19, 4:50 p.m.
No unfortunately - the Reportable REST API only returns XML. The OSLC API returns a range of formats including JSON.

I agree - the XML is a bit of a pain, especially when you can only use the built in Javascript (or common browser libraries if you know it's client side execution)

Amol Wangate commented Jun 25 '19, 11:28 a.m.

Davyd - where can I get that OSLC API? I tried looking for it and got it but it was in rdf+xml format. Would u be able to provide me the link? would rather like to go with OSLC API if it indeed provides data in JSON format.


Ralph Schoon commented Jun 25 '19, 12:31 p.m. | edited Jun 25 '19, 12:31 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Google for OSLC, it is a standard. 

The standard specifies what is supported/must be supported and the common standard used to be xml+rdf in the past. So only a very few OSLC API implementations support JSON.

You can look up the OSLC Workshop on this site for more information. An implementation that helps with implementing access to the API is the Eclipse Lyo project.  


Davyd Norris commented Jun 25 '19, 8:32 p.m.

I had to add my reply as a separate answer because I didn't have enough characters - see below

2 other answers



permanent link
Amol Wangate (158) | answered Jun 28 '19, 8:48 a.m.
One last question Davyd & Ralph -
I've this REST API : https://xyx:8085/ccm/rpt/repository/workitem?fields=workitem/workItem[projectArea/name='Defect Management']/(id|summary|allExtensions[displayName='External ID']/(displayName|displayValue)) and it only returns limited number of recrods. However, I need all. What changes do I need to make to the mentioned url to get all the records.

Comments
Davyd Norris commented Jun 28 '19, 6:39 p.m.

How many records does it return?


Amol Wangate commented Jul 01 '19, 5:55 a.m.

100 records by default


permanent link
Davyd Norris (2.2k217) | answered Jun 25 '19, 8:31 p.m.
The OSLC API will give you back XML, JSON or ATOM feed data. To get JSON, add .json to your URL, and the 'Accept: application/json' header to your request. So for instance you can use this to get a list of Filed Against categories:

    var xhrArgs = {
      url : '/ccm/oslc/categories.json?oslc_cm.query=rtc_cm:projectArea="'
          + workItem.getValue(WorkItemAttributes.PROJECT_AREA)
          + '"%20and%20rtc_cm:archived=false',
      headers : {
        'Accept' : 'application/json'
      },
      handleAs : 'json'
    };

    jazzClient.xhrGet(xhrArgs).then(function(data) {
      data['oslc_cm:results'].forEach(function(item) {
        var cat = {
          name : item['dc:title'],
          fullName: item['rtc_cm:hierarchicalName'],
          id : item['rdf:resource'].split('/').pop(),
       };
    };
  };


Comments
Amol Wangate commented Jun 27 '19, 8:32 a.m.
This is helpful. Thank u Davyd!

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.