Querying the list of user stories for a project in Rally using REST API

3.3k views Asked by At

I need to get the list of e.g. user stories for a project in Rally using the REST API's directly.

I can get the project itself by using this URI:

https://rally1.rallydev.com/slm/webservice/v2.0/Project/1234567890

This will give me a JSON document with e.g. 22 "children". But as far as I can see the "children" are actually "Sub projects".

How can I query the items themselves?

I can get the item itself from this URI

https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/0987654321

... but how do I go from the "project" to the item?

According to the documentation I can query the URI for the project using a syntax like this:

https://rally1.rallydev.com/slm/webservice/v2.0/project?query=QueryString&order=OrderString

My question is: how do I construct the QueryString? I have a hard time finding any documentation of the format and syntax.

Any help will be greatly appreciated :-)

/Jesper

2

There are 2 answers

0
Andrew McGrath On

This is a pretty old question at this point, but maybe you're still looking for help.

If you're looking to load user story data, then you'll want to use this endpoint:

https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?

Then you were on the right track regarding providing a query string. Constructing queries can be quite tricky, especially when you have multiple filter criteria. In your case you will want to filter the user stories based on the project they belong to. It's best to use the project's ref as the filter. The ref is just "/project/" followed by the Object ID.

So the query ends up looking like this:

(project = "/project/123456789")

Adding that query as a parameter in the URL gives us this:

https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?query=(project = "/project/123456789")

Just replace the project ID with the project you're interested in and it should give you the user stories you're looking for. Just note that the default page size is 20. You can increase that by also adding a pageSize parameter to the URL.

0
Saurabh Gupta On

There is a simple way: Suppose you have different releases quarter-wise then you can mention the relase and what project you want to query. Project id you can note down from your URL bar also most of the time but we have Rally API also to get the project ID like i am mentioning below

https://rally1.rallydev.com/slm/webservice/1.29/subscription.js?fetch=Workspaces,Name,Projects&pretty=true

you can hit above api and check the project key under which all projects will be listed with the "_ref"(at last the projectID will be appended). Now back to our main question, set this id in your query below (Like i have set it as 12345678.)

https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement?query=((Release.Name = "Q1A2020") and (Project = "/project/12345678"))&fetch=Tasks,FormattedID,Name,TotalResultCount,_ref,pagesize=20

Bingo!! you will get the desired results. Let me know if you afec issues with APIS or you need defects and all information.