How to find custom attribute values in Reportable REST API output, limit output, and decode coded information
For background of my overall objective, please reference:
============================================
https://jazz.net/forum/questions/116952/use-reportable-rest-api-to-obtain-child-work-item-attributes-based-on-parent-and-child-attributes
Specific background:
================
In an attempt to achieve the overall objective, I am running the following statement:
It gives output like the following:
…
- <w<workItem>
<id>23</id>
<summary>(IT45107) CM 102 - CPRO Enhancement: stop placing cases into the flow with deceased NCP's</summary>
- <state>
<name>New</name>
<group>open</group>
</state>
<parent />
- <children>
<uniqueId>335be4668793f1cf99857a9bdf376b45</uniqueId>
<stateId>_3FhCsLKREeKGFqpUni6-Kw</stateId>
<itemId>__yc0ELKFEeKEModREAEZbg</itemId>
<contextId>_1iLsQK3yEeKjWoswhs7PZg</contextId>
<modified>2013-05-01T15:03:51.131-0400</modified>
<predecessor>_H-RmBLKGEeKGFqpUni6-Kw</predecessor>
<id>25</id>
<resolutionDate>2013-05-01T13:39:50.450-0400</resolutionDate>
<summary>(IT45107) CM 102 - CPRO Enhancement: BATCH_AGP_REFERRAL.PKB</summary>
<creationDate>2013-05-01T13:39:50.450-0400</creationDate>
<dueDate />
<description>(IT45107) CM 102 - CPRO Enhancement:</description>
<workflowSurrogate />
<tags />
<duration>-1</duration>
<timeSpent>-1</timeSpent>
<correctedEstimate>-1</correctedEstimate>
<modifiedBy />
<creator />
<owner />
<category />
<comments />
<customAttributes />
<customAttributes />
<subscriptions />
<projectArea />
<resolver />
<target />
<foundIn />
<stringExtensions />
<bigDecimalExtensions />
<dayModified>2013-04-30T20:00:00.000-0400</dayModified>
<commentCount>1</commentCount>
<subscriberCount>1</subscriberCount>
<state />
<type />
<severity />
<priority />
<parent />
<allExtensions />
<allExtensions />
<formattedSummary>(IT45107) CM 102 - CPRO Enhancement: BATCH_AGP_REFERRAL.PKB</formattedSummary>
<formattedDescription>(IT45107) CM 102 - CPRO Enhancement:</formattedDescription>
<stringComplexity />
<integerComplexity />
<floatComplexity />
<longComplexity />
<doubleComplexity />
</children>
- <children>
<uniqueId>0d938852163179b57add45938929357f</uniqueId>
<stateId>_W4Y_crKHEeKGFqpUni6-Kw</stateId>
<itemId>_m_B9wLKFEeKEModREAEZbg</itemId>
<contextId>_1iLsQK3yEeKjWoswhs7PZg</contextId>
<modified>2013-05-01T13:48:40.039-0400</modified>
<predecessor>_xqNHBbKFEeKGFqpUni6-Kw</predecessor>
<id>24</id>
…
</workItem>
- <workItem>
<id>25</id>
<summary>(IT45107) CM 102 - CPRO Enhancement: BATCH_AGP_REFERRAL.PKB</summary>
- <state>
<name>Accepted / Updated</name>
<group>closed</group>
</state>
- <parent>
<uniqueId>1e3794c9eadf746c50d5ee7db0c6a551</uniqueId>
<stateId>_lroxXrKHEeKGFqpUni6-Kw</stateId>
<itemId>_zNQDkLKEEeKEModREAEZbg</itemId>
<contextId>_1iLsQK3yEeKjWoswhs7PZg</contextId>
<modified>2013-05-01T13:50:19.365-0400</modified>
<predecessor>_Kn_2wbKFEeKGFqpUni6-Kw</predecessor>
<id>23</id>
<resolutionDate />
<summary>(IT45107) CM 102 - CPRO Enhancement: stop placing cases into the flow with deceased NCP's</summary>
<creationDate>2013-05-01T13:32:58.702-0400</creationDate>
<dueDate />
<description>Email from the user describing the requested change...</description>
<workflowSurrogate />
<tags />
<duration>-1</duration>
<timeSpent>-1</timeSpent>
<correctedEstimate>-1</correctedEstimate>
<modifiedBy />
<creator />
<owner />
<category />
<subscriptions />
<projectArea />
<resolver />
<target />
<foundIn />
<dayModified>2013-04-30T20:00:00.000-0400</dayModified>
<commentCount>0</commentCount>
<subscriberCount>1</subscriberCount>
<state />
<type />
<severity />
<priority />
<parent />
<children />
<children />
<children />
<children />
<children />
<children />
<children />
<formattedSummary>(IT45107) CM 102 - CPRO Enhancement: stop placing cases into the flow with deceased NCP's</formattedSummary>
<formattedDescription>Email from the user describing the requested change...</formattedDescription>
<stringComplexity />
<integerComplexity />
<floatComplexity />
<longComplexity />
<doubleComplexity />
</parent>
- <customAttributes>
<uniqueId>fe26317191e14ee011612e125e611a31</uniqueId>
<stateId>_zz8gRLHUEeKUr_CvpuH8pg</stateId>
<itemId>_c--0JLGnEeKUr_CvpuH8pg</itemId>
<contextId>_1iLsQK3yEeKjWoswhs7PZg</contextId>
<modified>2013-04-30T16:30:34.274-0400</modified>
<identifier>MICSES_Source_File_CI_Name</identifier>
<attributeType>smallString</attributeType>
<builtIn>false</builtIn>
<modifiedBy />
<projectArea />
</customAttributes>
- <customAttributes>
<uniqueId>cc173f0b0fcdceecd1f2e5d0c8327f28</uniqueId>
<stateId>_xWeaPbKCEeKGFqpUni6-Kw</stateId>
<itemId>_xWBuR7KCEeKGFqpUni6-Kw</itemId>
<contextId>_1iLsQK3yEeKjWoswhs7PZg</contextId>
<modified>2013-05-01T13:15:50.193-0400</modified>
<identifier>MICSES_Source_file_CI_Version_dec</identifier>
<attributeType>decimal</attributeType>
<builtIn>false</builtIn>
<modifiedBy />
<projectArea />
</customAttributes>
</workItem>
- <workItem>
<id>26</id>
…
Specific Questions
================
1) How do I use the Reportable REST API to return the actual value of the custom attributes “MICSES_Source_File_CI_Name” and “MICSES_Source_file_CI_Version_dec”?
2) Is there a way to ask the Reportable REST API to only return the fields I care about? (id, planned for, state, parent, child, MICSES_Source_File_CI_Name, MICSES_Source_file_CI_Version_dec) It seems that the output is providing a lot more information than that.
3) Do I need to worry about some of the coded values (like <itemId>_xWBuR7KCEeKGFqpUni6-Kw</itemId>)? If yes, how do I decode those?
Accepted answer
Some answers to your questions in bold, below:
1) How do I use the Reportable REST API to return the actual value of the custom attributes “MICSES_Source_File_CI_Name” and “MICSES_Source_file_CI_Version_dec”?
As you've found out, the workitem/customAttributes element doesn't return the values of those attributes; it returns metadata about the custom attributes that apply to this work item (e.g., the attribute id). To get the value of a custom attribute, look at the elements workitem/<type>Extensions (e.g., workitem/stringExtensions for custom attributes of type string). The custom values are stored as (key, value) pairs, where the key is the identifier of the custom attribute. So, you might use a fields argument like this:
fields=workitem/workItem/stringExtensions[key='MICSES_Source_File_CI_NameMICSES_Source_File_CI_NameMICSES_Source_File_CI_NameMICSES_Source_File_CI_NameMICSES_Source_File_CI_Name']/value
2) Is there a way to ask the Reportable REST API to only return the fields I care about? (id, planned for, state, parent, child, MICSES_Source_File_CI_Name, MICSES_Source_file_CI_Version_dec) It seems that the output is providing a lot more information than that.
You're getting a lot of data in your output because of field arguments like "children/*", which is returning all the child attributes of all the children for that work item. If you only want certain fields from the children, you need to specify them. Have you looked at using a reporting tool like Rational Publishing Engine? It would make it much easier to create reports based on the reportable REST API, since it can calculate the fields argument based on the data needed for the report (instead of you figuring out the URL by hand).
3) Do I need to worry about some of the coded values (like <itemId>_xWBuR7KCEeKGFqpUni6-KwitemId>)? If yes, how do I decode those?
I'm not sure what you mean by coded - the <itemId> is the unique UUID of the item, and is not meant to be readable.