HP ALM REST API - Get ALM Domains and Projects Together

Tutorial on how to get domains and projects from HP ALM using REST API together. Includes browser method, VB and C# functions to get them together.

HP ALM REST API - Get ALM Domains and Projects Together
Tutorial on how to get domains and projects from HP ALM using REST API together. Includes browser method, VB and C# functions to get them together

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 domains in the same browser window: http://youralmserver:port/qcbin/api/domains?include-projects-info=y
  6. Once you enter this url and press enter you will get the list of domains and projects under them. Resulting XML includes all domainss and projects you have access to in HP ALM.
  • For ALM Versions prior to 12.53
    In urls, replace api with rest
    e.g. http://youralmserver:port/qcbin/rest/domains?include-projects-info=y

    Refer HP ALM REST API - Authentication for details on how to sign-in in older versions of ALM.

    Sample Output

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
     <Domain Name="Domain1">
       <Project UID="172a-321-543-1" Name="Project1" /> 
       <Project UID="172a-321-543-2" Name="Project2" /> 
       <Project UID="172a-321-543-3" Name="Project3" /> 
     <Domain Name="Domain2">
       <Project UID="172a-321-543-11" Name="ProjectA" /> 
       <Project UID="172a-321-543-21" Name="ProjectB" /> 
       <Project UID="172a-321-543-43" Name="ProjectC" /> 
       <Project UID="172a-321-543-44" Name="ProjectD" /> 
       <Project UID="172a-321-543-56" Name="ProjectE" /> 
     <Domain Name="Domain3">
       <Project UID="172a-321-543-31" Name="ProjectX" /> 
       <Project UID="172a-321-543-25" Name="ProjectY" /> 

    Code Method

    Inputs Required
    Prameter Example / Comments
    HP ALM Base URL http://youralmurl:port/qcbin
    Authentication CookieContainer

    Pass the authentication cookiecontainer obtained while you authenticated.

    Refer HP ALM REST API - Authentication for details.


    In order to store Domain and Project information, create a class DomainProject
    Refer respective code sections for class definition

    VB Code to define DomainProject class

    Friend Class DomainProject
     Public Property Domain() As String
       Return m_Domain
      End Get
       m_Domain = Value
      End Set
     End Property
     Private m_Domain As String
     Public Property ProjectList As List(Of String) = New List(Of String)
     Public Overrides Function ToString() As String
            Return $"Domain: {Domain}{vbLf}Project Count: {ProjectList.Count}{vbLf}{vbTab}{ProjectList.Aggregate(Function(a,b) a + vbLf + vbTab + b)}{vbLf}"
     End Function
    End Class

    VB Code to get ALM Domains and Projects Together

    Private Function GetDomainProject(almBaseUrl As String, authenticationCookieContainer As CookieContainer) As List(Of DomainProject)
     Dim domainProjectList = New List(Of DomainProject)()
     Dim domainProjectRequest = CType(WebRequest.Create(almBaseUrl + "/api/domains?include-projects-info=y"), HttpWebRequest)
     domainProjectRequest.CookieContainer = authenticationCookieContainer
     Dim domainProjectRequestResponse = domainProjectRequest.GetResponse()
     Dim domainProjectRequestResponseStream = domainProjectRequestResponse.GetResponseStream()
     If domainProjectRequestResponseStream Is Nothing Then
      Return domainProjectList
     End If
     Using responseReader = New StreamReader(domainProjectRequestResponseStream)
      Dim responseString = responseReader.ReadToEnd()
      Dim responseXml = XElement.Parse(responseString)
      Dim projectListXml = responseXml.Descendants("Projects")
      Dim projectQuery = From project In projectListXml.Elements()
             Let domainName = project.Parent.Parent.FirstAttribute.Value
             Let projectName = project.Attribute("Name").Value
             Order By domainName, projectName
             Select New With {domainName, projectName}
      domainProjectList = projectQuery.GroupBy(Function(d) d.domainName).[Select](Function(p) New DomainProject With {.Domain = p.Key, .ProjectList = p.[Select](Function(q) q.projectName).ToList()}).ToList()
     End Using
     Return domainProjectList
    End Function


    Dim almDomainProjects = GetDomainProject(almBaseUrl, authenticationCookieContainer);
    For Each dp As DomainProject in almDomainProjects

    C# Code to define DomainProject class

    internal class DomainProject
     public string Domain { get; set; }
     public List ProjectList { get; set; }
     public override string ToString()
      return $"Domain: {Domain} \nProject Count: {ProjectList.Count} \n\t{ProjectList.Aggregate((a, b) => a + "\n\t" + b)}\n";

    C# Code to get ALM Domains and Projects Together

    private static IEnumerable GetDomainProject(string almBaseUrl, CookieContainer authenticationCookieContainer)
     var domainProjectList = new List();
     var domainProjectRequest = (HttpWebRequest)WebRequest.Create(almBaseUrl + "/api/domains?include-projects-info=y");
     domainProjectRequest.CookieContainer = authenticationCookieContainer;
     var domainProjectRequestResponse = domainProjectRequest.GetResponse();
     var domainProjectRequestResponseStream = domainProjectRequestResponse.GetResponseStream();
     if (domainProjectRequestResponseStream == null) return domainProjectList;
     using (var responseReader = new StreamReader(domainProjectRequestResponseStream))
      var responseString = responseReader.ReadToEnd();
      var responseXml = XElement.Parse(responseString);
      var projectListXml = responseXml.Descendants("Projects");
      var projectQuery = from project in projectListXml.Elements()
             let domainName = project.Parent.Parent.FirstAttribute.Value
             let projectName = project.Attribute("Name").Value
             orderby domainName, projectName
             select new { domainName, projectName };
      domainProjectList = (from d in projectQuery group d.projectName by d.domainName into dp select new DomainProject { Domain = dp.Key, ProjectList = dp.ToList() }).ToList();
     return domainProjectList;


    var almDomainProjects = GetDomainProject(almBaseUrl, authenticationCookieContainer);
    foreach (var dp in almDomainProjects)

  • For ALM Versions prior to 12.53
    In the code replace /api/domains with /rest/domains

    Sample Output

    Domain: Domain1
    Project Count: 3
    Domain: Domain2
    Project Count: 5
    Domain: Domain3
    Project Count: 2
  • Tip

    You can use this code to get information from all domains and projects without hard coding domain names and project names. Use the DomainProject class to get data from various Domain-Project combinations.



    AngularJS,3,Automation Testing,8,Blue Prism,1,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,Robotic Process Automation,1,RPA,1,Testing,15,UFT,8,VB,5,VBScript,1,Wordpress,1,
    Aneejian: HP ALM REST API - Get ALM Domains and Projects Together
    HP ALM REST API - Get ALM Domains and Projects Together
    Tutorial on how to get domains and projects from HP ALM using REST API together. Includes browser method, VB and C# functions to get them together.
    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 PREMIUM CONTENT IS LOCKED STEP 1: Share. STEP 2: Click the link you shared 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