Work items between 2 releases

In Release Management UI, we show a nice list of work items that are getting deployed as part of a deployment on an environment. In this post, I will talk about how you can get the equivalent list of work items programmatically.

Let us take an example where I have a release (with name RM_M136.9 ) that I want to deploy on my environment (with name R2_WEU1). For this release, here are the work items that you see in the UI.

Before we try to find out the same list using RM APIs, let us get the releaseId for release RM_M136.9 and environmentId for environment R2_WEU1.

- To get the release id, open the release and take the releaseId from the URL\_releaseProgress?releaseId=**4630482**&\_a=release-pipeline-progress”.
- To get the environment id, open the release definition, click on the environment and take the environmentId from the URL.\_releaseDefinition?definitionId=17&\_a=definition-tasks\&environmentId=**2461**.

Now that we have both these Ids, let us use RM APIs to get the same work item list.

1. First of all, get the last deployed release on an environment. To do that, you can do that using this rest API and the response will contain the last deployed releaseId.$top=1

Example: - The response had releaseId 4580686 when following call was made.$top=1
2. Now get the work items between the release that you are about to deploy and the above found base release. To do that, use the following rest API which will return you the list of work items.$top=250
Example: - The response had following workItem Ids when this call was made.

Request:$top=250 Response: { "count": 47, "value": [ { "id": "1298228", "url": "" }, { "id": "1292030", "url": "" }, …. ] }
Please try this out and do let us know in case it does not work for you.

Enjoy !!