Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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

0 votes

Comments

No details => No answers. QED

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?

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. 

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
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

1 vote

Comments
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.

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)

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.

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.  

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


2 other answers

Permanent link
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(),
       };
    };
  };

0 votes

Comments
This is helpful. Thank u Davyd!


Permanent link
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.

0 votes

Comments

How many records does it return?

100 records by default

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Jun 17 '19, 10:15 a.m.

Question was seen: 1,825 times

Last updated: Jul 01 '19, 5:55 a.m.

Confirmation Cancel Confirm