$show=home$hide=mobile-page

HP ALM REST API - Get ALM Domains

Tutorial on how to get domains from HP ALM using REST API. Includes the browser method, VB and C# functions to get domains. Learn more @aneejian

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

Contents of this post.

[post_ads]

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
  6. Once you enter this url and press enter you will get domain list you have access to in xml format.
  •  
  • For ALM Versions prior to 12.53
    In urls, replace api with rest
    e.g. http://youralmserver:port/qcbin/rest/domains

    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" ?> 
    <Domains>
     <Domain Name="Domain1" /> 
     <Domain Name="Domain2" /> 
     <Domain Name="Domain3" /> 
     <Domain Name="Domain4" /> 
     <Domain Name="Domain5" /> 
    </Domains>

    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.

    [post_ads_2]

    VB Code to get ALM Domains

    Private Function GetDomains(almBaseUrl As String, authenticationCookieContainer As CookieContainer) As IEnumerable(Of String)
     Dim domainList = New List(Of String)()
     Dim domainRequest = CType(WebRequest.Create(almBaseUrl + "/api/domains"), HttpWebRequest)
     domainRequest.CookieContainer = authenticationCookieContainer
     Dim domainResponse = domainRequest.GetResponse()
     Dim domainResponseStream = domainResponse.GetResponseStream()
     If domainResponseStream Is Nothing Then
      Return domainList
     End If
     Using responseReader = New StreamReader(domainResponseStream)
      Dim responseString = responseReader.ReadToEnd()
      Dim responseXml = XElement.Parse(responseString)
      Dim domainQuery = From domain In responseXml.Elements() Select New With {.domainName = domain.Attribute("Name").Value}
      domainList.AddRange(domainQuery.[Select](Function(domain) domain.domainName))
     End Using
     Return domainList
    End Function

    Usage

    Dim almDomains = GetDomains("http://youralmurl:port/qcbin", AuthenticationCookieContainer)
    Console.WriteLine(almDomains.Aggregate(Function(a, b) a + vbLf + b))

    C# Code to get ALM Domains

    private static IEnumerable GetDomains(string almBaseUrl, CookieContainer authenticationCookieContainer)
    {
     var domainList = new List();
     var domainRequest = (HttpWebRequest)WebRequest.Create(almBaseUrl + "/api/domains");
     domainRequest.CookieContainer = authenticationCookieContainer;
     var domainResponse = domainRequest.GetResponse();
     var domainResponseStream = domainResponse.GetResponseStream();
     if (domainResponseStream == null) return domainList;
     using (var responseReader = new StreamReader(domainResponseStream))
     {
      var responseString = responseReader.ReadToEnd();
      var responseXml = XElement.Parse(responseString);
      var domainQuery = from domain in responseXml.Elements()
            select new { domainName = domain.Attribute("Name").Value };
      domainList.AddRange(domainQuery.Select(domain => domain.domainName));
     }
     return domainList;
    }

    Usage

    var almDomains = GetDomains("http://youralmurl:port/qcbin", authenticationCookieContainer);
    Console.WriteLine(almDomains.Aggregate((a, b) => a + "\n" + b));

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

    Sample Output

    Domain1
    Domain2
    Domain3
    Domain4
    Domain5
    

    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 Domains
    HP ALM REST API - Get ALM Domains
    Tutorial on how to get domains from HP ALM using REST API. Includes the browser method, VB and C# functions to get domains. Learn more @aneejian
    https://1.bp.blogspot.com/-uNhh4K5GhZY/WNFq49MroqI/AAAAAAAAALw/rWy08jwYcDgXPqebyRyCDCufabtzq8MLwCLcB/s320/getDomains.jpg
    https://1.bp.blogspot.com/-uNhh4K5GhZY/WNFq49MroqI/AAAAAAAAALw/rWy08jwYcDgXPqebyRyCDCufabtzq8MLwCLcB/s72-c/getDomains.jpg
    Aneejian
    http://www.aneejian.com/2017/03/hp-alm-rest-api-get-alm-domains.html
    http://www.aneejian.com/
    http://www.aneejian.com/
    http://www.aneejian.com/2017/03/hp-alm-rest-api-get-alm-domains.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