It's all about the answers!

Ask a question

How to read the values of custom workitem attributes using REST


Dave Sinclair (21179) | asked Jan 21 '15, 5:42 p.m.
I am trying to use the REST API on Jazz 4.6 to access a workitem.  All works well for the 'normal' attributes but our workitems have several custom fields.  These do not appear in the results of my query.  How can I read the values of the custom attributes in a workitem using the REST API?

For instance, I use the following query to access the contents of workitem 6460:

https://myjazzserver:9443/jazz/oslc/contexts/_8IloQGRKEeGMeeKcLm-Fsg/workitems?oslc_cm.query=dc:identifier="6460"

Alternatively I use:

https://myjazzserver:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/6460?_mediaType=text/json

both return the predefined attrributes but neither return the custom attributes.

Many thanks.



Comments
Dave Sinclair commented Jan 22 '15, 6:25 p.m.

Thanks for the answer, Brian.  The Reportable REST API helps a bit.  However I still can't resolve the actual values of the customisable attributes.  Here's an example of my problem:

We have a customised attribute in our Workitem called Dev_Fix_Plan_Attribute.  It is a smallStringValue so when I do a query like:

https://myjazzserver:9443/jazz/rpt/repository/workitem?fields=workitem/workItem[id=41608]/(/)

to get everything about workitem 41608 the Dev Fix Plan attribute is described as:

'Dev_Fix_Plan_Attribute' => {
                        'smallStringValue' => 'Development_Fix_Plan.literal.l1',
                        'longValue' => {},
                        'decimalValue' => {},
                        'displayValue' => 'Development_Fix_Plan.literal.l1',
                        'booleanValue' => {},
                        etc


Dave Sinclair commented Jan 22 '15, 6:27 p.m.



continued....
                        'type' => 'smallStringValue',
                        'helperId' => '_PLvB8KHDEeSiubWmwVW87Q',
                        'timestampValue' => {},
                        'doubleValue' => '0.0',
                        'largeStringValue' => {},
                        'displayName' => 'Dev Fix Plan'

which is very nearlly what I need.  The Dev Fix Plan customised attribute is an enumrated value I think, and we are being told the index of the enumation is

Development_Fix_Plan.literal.l1

but I don't know how to look up the the real value of Development_Fix_Plan.literal.l1


1
Donald Nong commented Jan 22 '15, 9:01 p.m.

I'm surprised that even the second URL did not give you the custom attributes, as it works without any issues in my environment. Did you get any attributes that are in the "rtc_ext" name space at all?


Dave Sinclair commented Jan 23 '15, 3:40 a.m.

Hello Donald:

No, I'm afraid there are no attributes in the "rtc_ext" name space at all in the second query.  Is your environment perhaps later than mine (I'm at Jazz 4.0.6 at the moment)

2 answers



permanent link
Brian Fleming (1.6k11928) | answered Jan 23 '15, 8:36 a.m.
Like Donald, I can also see custom attributes returned by a request of this format: https://myjazzserver:9443/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/6460?_mediaType=text/json

In any case, try the following query to get the display value of an enumeration literal id:

https://server:port/ccm/rpt/repository/workitem?fields=workitem/projectArea/enumerations/literals[id='Development_Fix_Plan.literal.l1']/name

In my testing this query returns a large number of empty tags like this:
<enumerations></enumerations>
but only one tag that actually has a value:
<enumerations><literals><name>$</name></literals></enumerations>
Depending on how many enumerations are defined in your instance you may have to page through the result set to see the correct value. 

permanent link
Brian Fleming (1.6k11928) | answered Jan 22 '15, 1:50 p.m.
You could use the Reportable REST API, with a query such as:
https://server:port/jazz/rpt/repository/workitem?fields=workitem/workItem[id=6460]/allExtensions/*

Reportable REST API documentation can be found here:
https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI

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.