It's all about the answers!

Ask a question

Finding out if an RTC build is tagged through the REST API

John Harvey (612) | asked Aug 27 '13, 4:16 p.m.

I've learned a little about the resful apis, and am interesting in getting information about builds that we have applied a tag to.

I can successfully run this sort of query:

I also noticed that you can list out different parameters besides buildStatus / label / timeTaken.
I found what looked to be a comprehensive list here:

I noticed 2 things:
1) compilationResults doesn't seem to work as a field
2) There is no field for tags

Can you suggest an alternative way with the REST API for me to check if a build has a tag associated with it?
Additionally, is there a limit to the amount of results returned, and is there a way to query for all results?

Any help would be appreciated!

Accepted answer

permanent link
Nick Edgar (6.5k711) | answered Sep 04 '13, 8:48 p.m.
You could also try, e.g.

This uses the internal REST interface supporting our web UI and VS clients.  The _prettyPrint arg is just for debugging.  Normally you'd specify an Accept header with text/json as the format, and omit the _prettyPrint.
John Harvey selected this answer as the correct answer

John Harvey commented Sep 10 '13, 10:14 a.m.

Hi Nick,

Thank you very much for this reply.  This actually works quite well!
I think I'll still keep 279053 open to see if I can get that function ported to the documented REST api, but this is really a cool solution, and works like a champ.

I did have one follow-up; this may be a simple question, but I noticed that with such a query I get "all" results, whereas with the rest-API, I'm limited to 100 results (so, if my build definition has 150 builds, I only get 100 through the original REST call I was making).  Is there a parameter I need to set on the restful api so that I don't have limited results?  Not sure if you'd know that offhand.


John Harvey commented Sep 10 '13, 1:48 p.m.

For anyone watching, the limit to 100 can be stretched by adding:

to the end of a query.

For example:
https://<jazz_repo>/jazz/rpt/repository/build?fields=build/buildResult[buildDefinition/id="<my_stream>" and buildStatus="OK" and buildState="COMPLETED" and personalBuild=false]/(buildDefinition/projectArea/name|buildStatus|buildState|label|timeTaken|personalBuild|startTime|timeWaiting|buildDefinition|itemId)&size=1000

The default is 100; the above works great if the number of build results > 100 but < 1000 results.

3 other answers

permanent link
John Harvey (612) | answered Aug 30 '13, 9:02 a.m.
Based on my investigation, it seems that you cannot query for tags through the build rest-API.
I really wish you could.

I came up with an alternative plan:
1) Query for good builds, and add the itemId parameter
https://<jazz_repo>/jazz/rpt/repository/build?fields=build/buildResult[buildDefinition/id="<my_stream>" and buildStatus="OK" and buildState="COMPLETED" and personalBuild=false]/(buildDefinition/projectArea/name|buildStatus|buildState|label|timeTaken|personalBuild|startTime|timeWaiting|buildDefinition|itemId)
2) Using the itemId's, query this:

Unfortunately, this means that I have to loop for every itemId, through every stream (so, a double-for loop), whereas if the tag information was available as part of the build restful api, I could just have a single loop.

So, I would love to have that functionality!  It's the difference of 1 minute vs. 20 minutes, so it'd be great to have in a future version of the restful api.

I also wonder.. what is the second site I'm hitting there?  It doesn't seem to be part of the restful api; so, what is it?  I see it referenced in a few docs on the web, so it's definitely valid.  Is it ok for me to hit that link?

permanent link
John Harvey (612) | answered Sep 04 '13, 2:55 p.m.
If anyone follows this thread, I have raised enhancement 279053 to make the request to add the tags field to the restful api.

Heres the link:

permanent link
Nick Edgar (6.5k711) | answered Sep 10 '13, 2:59 p.m.
edited Sep 10 '13, 3:00 p.m.
Regarding paging, if there is more to the result, it should include a rel="next" URL in the top element.
e.g. for''%5D/(buildDefinition/projectArea/name%7Clabel%7CbuildStatus%7CtimeTaken)
the top element is:
<build Version="1.0.0" rel="next" href="">

For more details, see the whitepaper link in the General Documentation section of:

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.