$show=home$hide=mobile-page

HP ALM REST API - Get ALM Releases

Tutorial on how to get releases under a project in HP ALM using REST API. Includes browser method, VB and C# functions to get releases.

Tutorial on how to get releases under a project in HP ALM using REST API. Includes browser method, VB and C# functions to get releases

Tutorial on how to get releases under specified domain using HP ALM REST API.

Contents of this post.

Web Browser Method

  1. Open your favorite browser.
  2. Enter HP ALM REST API url: http://youralmserver:port/qcbin/api/authentication/sign-in
  3. Enter you ALM User Name and Password in the prompt that you get on navigating to the above url.
  4. Once successful authentication has occurred you will get a blank page.
  5. Now enter the url to get releases in the same browser window: http://youralmserver:port/qcbin/rest/domains/domainName/projects/projectName/releases (Domain name and Project name is case sensitive. Use the name as displayed in ALM.)
  6. Once you enter this url and press enter, you will get the list of releases under the project under the domain you specified in the url in xml format.
[post_ads]

Sample Output

<?xml version="1.0" encoding="UTF-8"?>
<Entities TotalResults="1">
   <Entity Type="release">
      <ChildrenCount>
         <Value>0</Value>
      </ChildrenCount>
      <Fields>
         <Field Name="req-count">
            <Value>0</Value>
         </Field>
         <Field Name="ver-stamp">
            <Value>30</Value>
         </Field>
         <Field Name="description">
            <Value>Release Description</Value>
         </Field>
         <Field Name="scope-items-count">
            <Value>0</Value>
         </Field>
         <Field Name="start-date">
            <Value>2015-08-05</Value>
         </Field>
         <Field Name="has-attachments">
            <Value />
         </Field>
         <Field Name="end-date">
            <Value>2015-08-19</Value>
         </Field>
         <Field Name="last-modified">
            <Value>2016-10-06 00:06:25</Value>
         </Field>
         <Field Name="name">
            <Value>Release1</Value>
         </Field>
         <Field Name="milestones-count">
            <Value>2</Value>
         </Field>
         <Field Name="id">
            <Value>1003</Value>
         </Field>
         <Field Name="parent-id">
            <Value>104</Value>
         </Field>
      </Fields>
      <RelatedEntities />
   </Entity>
   <singleElementCollection>false</singleElementCollection>
</Entities>

Code Method

Inputs Required
Prameter Example / Comments
HP ALM Base URL http://youralmurl:port/qcbin
HP ALM Domain Name

Enter the name of the domain from which you want the list of projects.

Refer HP ALM REST API - Get ALM Domains for details on how to get domains from ALM.

HP ALM Project Name

Enter the name of the project from which you want the list of releases.

Refer HP ALM REST API - Get ALM Projects for details on how to get projects from ALM.

Authentication CookieContainer

Pass the authentication cookiecontainer obtained while you authenticated.

Refer HP ALM REST API - Authentication for details.

[post_ads_2]

In order to store Release information, create a class ProjectReleases
Refer respective code sections for class definition

VB Code to define ProjectReleases class

Friend Class ProjectReleases
 Public Property ReleaseId() As Integer
 Public Property ReleaseName() As String
 Public Property ReleaseStartDate() As Date
 Public Property ReleaseEndDate() As Date

 Public Overrides Function ToString() As String
  Return $"Release ID: {ReleaseId}{vbLf}Release Name: {ReleaseName}{vbLf}Release Start Date: {ReleaseStartDate}{vbLf}Release End Date: {ReleaseEndDate}{vbLf}{vbLf}"
 End Function
End Class

VB Code to get Releases under Project

Private Function GetProjectReleases(almBaseUrl As String, domainName As String, projectName As String, authenticationCookieContainer As CookieContainer) As IEnumerable(Of ProjectReleases)
 Dim projectReleasesList = New List(Of ProjectReleases)()
 Dim releaseRestApiUrl = $"{almBaseUrl}/rest/domains/{domainName}/projects/{projectName}/releases"
 Dim projectReleasesRequest = CType(WebRequest.Create(releaseRestApiUrl), HttpWebRequest)
 projectReleasesRequest.CookieContainer = authenticationCookieContainer
 Dim projectReleasesResponse = projectReleasesRequest.GetResponse()
 Dim projectReleaseResponseStream = projectReleasesResponse.GetResponseStream()
 If projectReleaseResponseStream Is Nothing Then
  Return projectReleasesList
 End If
 Using responseReader = New StreamReader(projectReleaseResponseStream)
  Dim responseString = responseReader.ReadToEnd()
  Dim responseXml = XElement.Parse(responseString)
  Dim entitiesXml = responseXml.Descendants("Entity")
  Dim releaseQuery = (From e As XElement In entitiesXml
       Let relId = e....Single(Function(x) x.Attribute("Name").Value = "id").Value
       Let relName = e....Single(Function(x) x.Attribute("Name").Value = "name").Value
       Let relStartDate = e....Single(Function(x) x.Attribute("Name").Value = "start-date").Value
       Let relEndDate = e....Single(Function(x) x.Attribute("Name").Value = "end-date").Value
       Select New ProjectReleases With {.ReleaseId = relId, .ReleaseName = relName, .ReleaseStartDate = relStartDate, .ReleaseEndDate = relEndDate}
        ).ToList()
  projectReleasesList = releaseQuery
 End Using
 Return projectReleasesList
End Function

Usage

Dim projectReleases = GetProjectReleases(almBaseUrl, "domainName", "projectName", authenticationCookieContainer)
For Each pr As ProjectReleases In projectReleases
 Console.WriteLine(pr.ToString())
Next

C# Code to define ProjectReleases class

internal class ProjectReleases
{
 public int ReleaseId { get; set; }
 public string ReleaseName { get; set; }
 public DateTime ReleaseStartDate { get; set; }
 public DateTime ReleaseEndDate { get; set; }

 public override string ToString()
 {
  return $"Release ID: {ReleaseId}\nRelease Name: {ReleaseName}\nRelease Start Date: {ReleaseStartDate}\nRelease End Date: {ReleaseEndDate}\n\n";
 }
}

C# Code to get Releases under Project

private static IEnumerable GetProjectReleases(string almBaseUrl, string domainName,
 string projectName, CookieContainer authenticationCookieContainer)
{
 var projectReleasesList = new List();
 var releaseRestApiUrl = $"{almBaseUrl}/rest/domains/{domainName}/projects/{projectName}/releases";
 var projectReleasesRequest = (HttpWebRequest)WebRequest.Create(releaseRestApiUrl);
 projectReleasesRequest.CookieContainer = authenticationCookieContainer;
 var projectReleasesResponse = projectReleasesRequest.GetResponse();
 var projectReleaseResponseStream = projectReleasesResponse.GetResponseStream();
 if (projectReleaseResponseStream == null) return projectReleasesList;
 using (var responseReader = new StreamReader(projectReleaseResponseStream))
 {
  var responseString = responseReader.ReadToEnd();
  var responseXml = XElement.Parse(responseString);
  var entitiesXml = responseXml.Descendants("Entity");
  var releaseQuery = (from entity in entitiesXml
       select entity.Descendants("Field")
    into releaseFields
       select releaseFields as IList ?? releaseFields.ToList()
    into relElements
       let relId = relElements.Single(x => x.Attribute("Name").Value == "id").Value
       let relName = relElements.Single(x => x.Attribute("Name").Value == "name").Value
       let relStartDate = relElements.Single(x => x.Attribute("Name").Value == "start-date").Value
       let relEndDate = relElements.Single(x => x.Attribute("Name").Value == "start-date").Value
       select new ProjectReleases { ReleaseId = int.Parse(relId), ReleaseName = relName, ReleaseStartDate = DateTime.Parse(relStartDate), ReleaseEndDate = DateTime.Parse(relEndDate)})
   .ToList();
  projectReleasesList = releaseQuery;
 }
 return projectReleasesList;
}

Usage

var projectReleases = GetProjectReleases(almBaseUrl, "domainName", "projectName", authenticationCookieContainer);
foreach (var pr in projectReleases)
{
 Console.WriteLine(pr.ToString());
}

Sample Output

Release ID: 1003
Release Name: Release1
Release Start Date: 05-12-2015
Release End Date: 05-01-2016

Release ID: 1004
Release Name: Release2
Release Start Date: 05-12-2015
Release End Date: 05-01-2016

Release ID: 1005
Release Name: Release3
Release Start Date: 05-12-2015
Release End Date: 05-01-2016
  •  
  • Tip

    You can get additional release details from other fields available in ALM. Add fields to the class and release query in code.

    COMMENTS





    Name

    AngularJS,3,Automation Testing,8,CSharp,5,Disqus,1,Excel,2,HP ALM,5,HTML5,1,ISTQB,2,Java Script,2,Manual Testing,7,Photography,1,Quiz,2,REST API,5,Testing,15,UFT,8,VB,5,VBScript,1,Wordpress,1,
    ltr
    item
    Aneejian: HP ALM REST API - Get ALM Releases
    HP ALM REST API - Get ALM Releases
    Tutorial on how to get releases under a project in HP ALM using REST API. Includes browser method, VB and C# functions to get releases.
    https://4.bp.blogspot.com/-F5xVIZhgsGc/WN0R9dA6UzI/AAAAAAAAANk/GcO0XHRMuvUfAGJuAkka9e2wDhY-cbH7ACLcB/s320/projectReleases.jpg
    https://4.bp.blogspot.com/-F5xVIZhgsGc/WN0R9dA6UzI/AAAAAAAAANk/GcO0XHRMuvUfAGJuAkka9e2wDhY-cbH7ACLcB/s72-c/projectReleases.jpg
    Aneejian
    http://www.aneejian.com/2017/03/hp-alm-rest-api-get-alm-releases.html
    http://www.aneejian.com/
    http://www.aneejian.com/
    http://www.aneejian.com/2017/03/hp-alm-rest-api-get-alm-releases.html
    true
    5798203121010168414
    UTF-8
    Loaded All Posts No posts found VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU ARCHIVE SEARCH ALL POSTS No post found which matches with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy