Software Testing

ALM How to Get Started Using the ALM REST API

By Test Guild
  • Share:
Join the Guild for FREE

ALM 11 – GETTING STARED WITH REST API

With the release of ALM 11, HP now offers an API that allows the user to interact with QC/ALM using REST. Rather than writing OTA code, one can now accomplish some of the same functionality using a browser as a client – no code writing needed.

Of course, you can also use tools like soapUI to work with ALM or create custom applications using languages like VBscript, C# and Java that interact with ALM.

But to keep it simple, we'll start by taking a look at how to get started using your browser as a client.

Getting started using your browser as a client

The first thing you'll need to do before using the ALM REST API is to authenticate your user. You can do this by obtaining a session cookie which returns a token that, by default, times out after one hour of inactivity.

Authenticate your user

1. Determine whether your user is currently authenticated by navigating to:

http://yourALMServer/qcbin/rest/is-authenticated

If your user is not currently authenticated, you'll get an HTTP Status Code 401.

2. To authenticate your user, navigate to:

http://yourALMServer/qcbin/rest/is-authenticated?login-form-required=y

3. Enter the ALM login name and password you want to authenticate:

 

4. If your ALM user is authenticated, you'll get the following XML:

 

How to READ an ALM defect

You should now be authenticated. Cool! Next, let's make sure we're able to retrieve the very first defect in ALM.

 

1. To READ an ALM defect record, place the following URL (using your ALM instance info) into your browser:

 

http://yourALM/qcbin/rest/domains/yourDomain/projects/yourProject/defects/1

 

2. The first defect should populate your browser with its XML info:

 

 

Although our example returned info for a defect in ALM, you can also read info for the other ALM entities, which are:

 

  • Defects
  • Resources
  • Requirements
  • Tests
  • Test lab

For example – if we wanted to read the first requirement info from ALM, we would simply change the defect URL we used to point to requirements instead of defects:

 

http://yourALM/qcbin/rest/domains/yourDomain/projects/yourProject/requirements/1

Other common tasks you can perform

We saw in the example above how easy it is to READ an existing record in ALM. Some other common tasks that can be performed using the ALM API are:

 

  • Create
  • Delete
  • Read
  • Update

That should be enough info to get you started using the ALM REST API. For more info, be sure to check out HP's ALM REST API doc – and as always, drop me a line with any questions or comments!

  1. Hi Joe,

    I would like to understand how do I perform database queries using REST API. Similar to using the tdconnectin.command object, used to query multiple tables, is there a way to accomplish this using REST?

    Regards,
    Ganesh.

  2. Hi,

    I am trying to access the rest api via python. However, I seem to be unable to authenticate. Would you have any sample python code that I can use as an example?

  3. Hi Joe,

    Is there any reference document for REST APIs for ALM>

    Thanks
    Vineet

  4. Hi,
    How to delete, update a defect in QC by using REST API ( in browser).

  5. Hi Joe,
    As mentioned in the topic “ALM 11 – GETTING STARED WITH REST API ” , about reading a defect. I need a detailed steps for deleting and updating a defect or any entity. can any one help me in this?

  6. Hi Joe,

    I am trying to access the URL with our ALM path, however i am seeing the error “The requested resource (/qcbin/rest/is-authenticated) is not available”. Please help me with this. Thanks!

    Regards,
    Jayashree SN

  7. Hi Joe,

    Great site and good articles. I am using QC 11.52 and trying to write a VAPI-XP automated test case using perl script and calling a java program through it. I am using the VAPI test wizard but it asks me to download BSF (Bean Scripting Framwork). I have already downloaded it but still it and placed the path in the classpath of environment variable but still it gives me the same JVM not founf error. Can you please let me know if it is even possible to do what I am doing and if yes what am I missing.

    Require your immediate help.

    Thanks,
    Atul

  8. Hi Atul I have not seen this issue. If you go to a command prompt and type java -version does it find the java version info? If not then it is definitely a path issue not being properly defined in you environment variables. What is throwing the JVM not found error ALM?

  9. Hi!
    Nice post.

    Do you have any examples on how to post(create) or delete a defect or any other entity?

    Regards!

  10. Hi Joe,
    Thanks for this wonderful Post.I need a solution for this.
    I need to pull defects that are not linked to any Test cases alone using Rest API.I tried several ways like, 1.Putting cross filter with Defects and Test Set
    2. http://ALM SERVER/qcbin/rest/domains/xxx/projects/YYY/defects/1/defect-links.This seems to work for only 1 defect.How can I retrieve the same info for a group of defects?
    CAn any one help me plz

  11. Thanks Joe,Could you please let us know the Website or blog where you found it.(ALM REST API Wrapper)

  12. Thanks joe, your document helped me to achieve my first step of authenticating with ALM 11.0, i was struggling for such a document for almost 3 weeks.
    I need your help in the below query. I authenticated successfully but later when i used the below query to GET data it was saying unauthorized. Can you please help me why was it saying unauthorized here.
    http://:/qcbin/rest/domains//projects//test-sets/72076

  13. Hi joe.I need Defect lists that are not linked to any test cases alone.I do not have much knowledge in JAVA.But I use Parasoft tool so I need to code in Java only.Could anyone please help me in this?

  14. Please guide me the details step to configure soapui 4.6 with ALM 11 ??

    For example how to do a Post/Get request for defect entity, i am getting authentication error as “HTTP Status 401 – An Authentication object was not found in the SecurityContext” even though i am passing all the authentication parameters with the soap request.

  15. I’m having trouble with the API. I can insert a valid defect fine, but the problem arises when I try to insert a defect with a problem, like for example the data I am trying to insert is longer than the ALM field can handle. Instead of rejecting the input, the API allows the attempt, then creates an empty defect with only the Defect ID. Obviously I will try not to insert invalid data, but you never know if a field will be changed or deleted on the ALM side. Is there some way to tell ALM to reject my API input instead of creating an empty defect?

  16. Hi,

    Please help!!!!!

    Am working on this REST API. I have a problem now and need to know whether it is possible to read tables using REST API.
    I have a table “common_settings” related to a project, it contains all the settings related to that project.

    Thanks in advance.

  17. Hi Dear Friend,
    To login in HP/ALM using REST, I am using following code.
    Response response=given().that().parameter(“j_username”,userName).parameter(“j_password”, password).when().get(“http://x-xxxx.YY:YYYY/qcbin/rest/is-authenticated?login-form-required=y”).then().extract().response();
    System.out.println(response.asString());
    But i am not able to. I am getting login page as reponse and not XML that you told. If i logged in manually, I am getting XML. Please help me out asap, others too who all are visitng this page.
    Thanks in advance.
    Regards,
    Pratik.

  18. I have found that your comments where the most helpful if any thing that I have found on this subject.

    I have a question. When I connect through the browser and run the following query and get a single response.
    tests?query={name[navToDonationAdjustmentsPageInternalAccountIconTest]}
    but when I do the same thing through my java app it return the complete collection.

    Any ideas?

  19. Hi Joe,

    It looks like the location for that HP ALM Rest Wrapper has been moved as it now comes upwith not found on codeplex. Do you have a copy or know the location for the new site?

  20. Hi Mark – sorry I don’t know – I can’t find it either now. let me see if I have it on any of my local machines, if i do I will place it in my downloads sections.

  21. Hi Joe,

    Could you please tell me how to update a test status in test lab using java code so that i can update the test status after execution of my junit tests.

    please help

    Thanks
    Vineeth Varghese

  22. Hi Joe,

    We have a requirement to update the test case id in QC after executing our selenium automation test cases using Bamboo. Could you please help me to get some idea on doing this. Please advise

    Thanks
    Vineeth Varghese

  23. I am trying to create a testcase in QC using REST, I refered the documentation examples “createDeleteExample” where it is there for “requirements”. I tried the similar way for creating test, “login ” happens, but throws exception during “post” operation. Response code returned is “500” – Internal server error.
    i have used in the request header the following xml schema
    String entityToPostXml =
    (“test”
    + Double.toHexString(Math.random()) + “”);
    Why that exception return code”500″ occured?

  24. Quality Center is a powerfull testing process tool. Including as well defect managment.

    As a QA manager, my main problematic was to manage several defects coming from many QC projects. And so, how to gather all these defect in an unic view.
    Other topic, developers working with ubuntu or any else OS other than internet explorer that should be able to the list of defect…

    Got it with QC DASHBOARD!

    A web client for Quality Center, runnable from any web browser (Opera, Firefox, Chrome), which also provides an responsive and unified view for all my Quality Center projects.
    Simple and clear web interface, it’s also usefull to get dedicated business views, for instance to prepare my next releases, display directly latest created defect and many other features.

    Let’s share it : http://www.qc-dashboard.com

  25. Hi Joe,

    Thanks for your wonderful post.

    By following your examples, I am able authenticate and get the defect information in xml format, but my requirement is to access a defect directly from a URL in HPALM itself.

    Can you please suggest a way?

    Appreciate your help with this.

    Thanks & Regards,
    BVR

  26. Hi,

    I am trying to access the rest API via python. However, I seem to be unable to authenticate. Would you have any sample python code that I can use as an example?
    I want to download the defects from ALM to Excel sheet by applying filters.

  27. Can you please let me know how to update a requirement status using rest api.The example shows for read.

  28. Hi Joe,

    Really it is a good article.

    I am trying to login ALM,and navigate to test lab ,then click on test set ,needs to execute using RUN button in test lab is it possible?

    if so please suggest me how to do this using automation .

    Thanks
    Sri

  29. I am running some tests and want to create defects on HP QC using the REST APIs – programatically.

    Let’s say some of the tests fail every day and it will take 30 days for it to be fixed. I want to create a defect on the first day, and NOT on subsequent runs. How can I know that a defect has been created (or not created).

  30. Specflow and HP ALM Integration
    I am looking for a solution on Specflow and HP ALM Integration.
    Can anyone help me out on this ?

  31. Hi

    I have the following issue and need a solution

    1. I want to pull the Test case Execution count using REST API based on the Test Lab Folder name. There can be many test sets inside that test lab folder and even test folders.
    Eg: Test Folder 1\Test Folder 2\Test Folder 3\Test Set 1

    I need to pull the execution count ( No. of Pass,Fail,No Run etc.,) by giving the parent test lab folder (Test Folder 1).

    2.I want to pull the ALM defects using REST API . I have many Favorites in my ALM as Public and Private . Is there a way i can pull the those using REST API ?

    3. I want to pull the number of test cases linked to a defect using REST API . I am able to pull the defects but not the linked test cases

    Can you please help me with these ?

  32. Did anyone tried using CURL and get the authentication?

    Basically here’s what I tried

    Step 1: Tried below and get response

    -> curl http://QCURL/qcbin/rest/is-authenticated

    Error 401 Authentication failed. Browser based integrations – to login append ‘?login-form-required=y’ to the url you tried to access.

    HTTP ERROR 401
    Problem accessing /qcbin/rest/is-authenticated. Reason:
    Authentication failed. Browser based integrations – to login append ‘?login-form-required=y’ to the url you tried to access.Powered by Jetty://

    Step 2: Tried below and didnt get any response back.

    -> curl http://QCURL/qcbin/rest/is-authenticated?login-form-required=y

    ->

    How to pass user name and password using CURL

  33. here is a complete reference by HP

    http://alm-help.saas.hpe.com/en/12.50/api_refs/REST_TECH_PREVIEW/ALM_REST_API_TP.html

    what this reference is missing is that after you have authenticated you must do a POST to /qcbin/rest/site-session this will give you two cookies XSRF-TOKEN and QCSESSION see here http://alm-help.saas.hpe.com/en/12.50/api_refs/REST_TECH_PREVIEW/ALM_REST_API_TP.html

    Once you have gotten those two cookies you can delete, update and create entities.

    I hope this helps.

  34. Hi friends, I need some help as I’m going crazy trying to solve a problem.

    In a Visual Basic macro I firstly authenticate an user and then I get session cookies, as specified in the previous post. After that, I launch some queries to get data from test cases, defects, and so other QC instances.

    My problem is that each one of these queries creates a connection (visible in ALM – Site Administration Site Connections). When the macro execution finishes, these connections remain opened…. and last week this produced a (big) problem in the server’s performance.

    I’ve implemented in the macro the logic for using “/authentication-point/logout” that releases the authentication cookie and it works because if I run a query after it the server returns 401. The problem is that this does not clear connections in the server.

    Do you have any idea?

    Thanks in advance for your answers.

  35. I’m trying to add a run in ALM using the REST API. I can successfully add a test run in the Test Runs page of ALM but back on the Test Lab page I have been unsuccessful. In order to update the test cases in the test set which is displayed on the Test Lab page I need to know the testcycl-id. There is at present no way to get that information. Does anyone have any idea how to get the testcycl-id?

  36. Get target-rel date
    How to get the target-rel date in defects .I am using java to read the defects and converting to jaxb clasess to map the attributes.Now unable to get the target-rel date because in “target-rel ” it is having the value as string and date is in “ReferenceValue”.I want to raed the both the values like ReferenceValue and value inside the target-rel .Please suggest.Thank You

  37. Hi,

    After authentication , i tried to get First Defect , and i am getting error message.

    “Exception Id: qccore.general-error”

  38. Hi, I am totally new in IT profession, my Manager has asked me to automate task of passing test cases and attaching the evidences to tests in test lab using VB scripting/macros. Can you please help me?

  39. Very good, can you show example for executing test case in test set. how execute test step and also how to finally execute the whole test case with pass or fail

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

What is Behavior Driven Development (An Introduction)

Posted on 03/21/2024

Love it or hate it—Behavior Driven Development is still widely used. And unfortunately ...

What is ETL Testing Tutorial Guide

Posted on 03/14/2024

What is ETL Testing Let's get right into it! An ETL test is ...

Open Test Architecture How to Update a Test Plan Field (OTA)

Posted on 11/15/2022

I originally wrote this post in 2012 but I still get email asking ...