It's all about the answers!

Ask a question

Fetching custom attributes for multiple items at the same time REST API


Staffan Solin (1319) | asked May 12 '17, 9:31 a.m.

I'm using REST API to fetch my data from NDG. I want to fetch the customAttribute attribute from the item so im using this url to reach the item I want to fetch: https://<localhost>/rm/publish/resources?resourceURI=_vu0WQVrkEeagjv4ysZcIGA


Then i'm using a Xpath expression to fetch the correct attributes, in this case: 
"//attribute:customAttribute[@attribute:name='Valid for Radio']/@attribute:literalName

Right now im looping through all the artifacts and that causes about 80 calls to the server. Which takes a very long time, is there a better way to fetch the custom attributes from multiple items?

One answer



permanent link
Donald Nong (14.5k614) | answered May 14 '17, 9:55 p.m.

Regardless custom attributes or built-in ones, if you want to retrieve them from multiple items, simply add the UUID after "resourceURI=", separated by commas. So your request URL will look like
https://<localhost>/rm/publish/resources?resourceURI=_vu0WQVrkEeagjv4ysZcIGA,_vu0WQVrkEeagjv4ysQneQP,_vu0WQVrkEeagjv4ysUslQD
or something like that.

Some points to note when using this technique.
1. Do not put too many IDs in the URL as it may end up too long and get rejected by the server.
2. With multiple items in the response, beware that your application needs more memory to cope with the content.
3. When using Xpath to read the attributes, make sure to read the ID as well, so that you know which attribute value is for which artifact/item.


Comments
Staffan Solin commented May 18 '17, 7:28 a.m.

Thanks for you answer Donald,


Eventhough im using the method you mentioned with combining all the items to one long string and doing calls it doesnt seem to work any faster. It is less calls to the database but when im doing my Xpath expression it takes a very long time. 

Might the loadtime be so long becuase my xpath expression is to complex?

Here is my xpath expression:

"//attribute:customAttribute[@attribute:name='Green']/@attribute:literalName | //attribute:customAttribute[@attribute:name='Identifier']/@attribute:name"

Is there any way to make it shorter if that is the reason for the long loadtime?

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.