Agile Central - LookBack API: How many times was a user story blocked?

Document ID : KB000112264
Last Modified Date : 28/08/2018
Show Technical Document Details
Question:
How can we use the API to how many times and all instances where a user story was Blocked?
Answer:
Since this request is for historical data of the artifact we will have to use the Lookback API.
Here is an example Lookback API query you can use:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/<<Workspace Object ID>>/artifact/snapshot/query.js?find={$and: [{"FormattedID":<<Artifact FormattedID>>}, {"Blocked": true}, {"_PreviousValues.Blocked": false}]}&fields=["_SnapshotDate","_SnapshotNumber","Blocked","Blocker","BlockedReason"]

This query is requesting all snapshots of the artifact where the Blocked state was 'true' along with a _PreviousValue of the Blocked state be 'false'. This combination suggests this was a snapshot where the artifact was set to be blocked. 

Here is a screenshot of the JSON output:
User-added image

In above JSON you see this artifact was blocked 3 times in snapshotNumbers 1, 5 and 10. You can see the timestamp of each block and the user (objectID) who blocked it.

Note:
The BlockedReason field might not necessarily conform to the same snapshots of the Blocked state. Reason may or may not have been given, and unnecessarily in the same snapshots. Therefore, if you needed to make certain of the BlockedReason that correspond to Block, you may need to run subsequent queries to find the change in the BlockedReason field subsequent to each of these snapshots.
Additional Information:
More on Lookback API: https://rally1.rallydev.com/analytics/doc/#/manual