Forum Discussion

lokessri's avatar
lokessri
Occasional Contributor
4 years ago

Api to get executions based on testcase key/id in zephyr scale

Hi Team,

 

I need an API to get executions based on test case key/id in zephyr scale

 

UI in Jira is somehow able to get this information as shown below, however I am unable to get the same data using api

Any insights will be helpful

  • Hi lokessri ,

    there is a way to do this using the internal API, but you must be aware that it is not supported or documented for public use which means, that you might run into undocumented changes down the line. You can also break a lot of stuff using the internal API but in your case ist's just a simple GET so no need to worry. 😉

     

    You can use the following endpoint to get the results for a test case by its internal id.

     

    .../jira/rest/tests/1.0/testcase/<test case id>/testresults?fields=testResultStatus(name,i18nKey,color),environment(name),key,userKey,assignedTo,jiraVersionId,estimatedTime,executionTime,executionDate,automated,testRun,testCase,issueLinks,sprint(name)

     

    This will return the same info you can see in the test case. Using the fields parameter you can filter the info you get. So if you only want the test cycle and execution key for example, it would be ?fields=key,testRun.

     

    To get the test case id from its key, you can use this.

    .../jira/rest/tests/1.0/testcase/<test case key>?fields=id

     

    Hope, this helps.

    Cheers

    Josh

  • josh42's avatar
    josh42
    Community Hero

    Hi lokessri ,

    there is a way to do this using the internal API, but you must be aware that it is not supported or documented for public use which means, that you might run into undocumented changes down the line. You can also break a lot of stuff using the internal API but in your case ist's just a simple GET so no need to worry. 😉

     

    You can use the following endpoint to get the results for a test case by its internal id.

     

    .../jira/rest/tests/1.0/testcase/<test case id>/testresults?fields=testResultStatus(name,i18nKey,color),environment(name),key,userKey,assignedTo,jiraVersionId,estimatedTime,executionTime,executionDate,automated,testRun,testCase,issueLinks,sprint(name)

     

    This will return the same info you can see in the test case. Using the fields parameter you can filter the info you get. So if you only want the test cycle and execution key for example, it would be ?fields=key,testRun.

     

    To get the test case id from its key, you can use this.

    .../jira/rest/tests/1.0/testcase/<test case key>?fields=id

     

    Hope, this helps.

    Cheers

    Josh

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Great advice josh42!

       lokessri please let the Community know if this helps in your situation.

    • lokessri's avatar
      lokessri
      Occasional Contributor

      Thanks for the solution Josh, is there a chance to break the system if we build automation surrounding this API, as we are looking to get details based on these APIs and have some gating logic built based on the data rendered by this API.

      Load that we are trying to add is about 3000 requests around the span 15 minutes

       

      Any inputs will help

       

    • Michael_Timpe's avatar
      Michael_Timpe
      New Contributor

      Hi,

      this seems to be a solution also for what I am looking for. Can you pls tell me on how to do the authentication for this and which URL has to be addressed. I tried with Jira and Zephyr access token. Both doesn't work. Do I need to take the smartbear URL (app.tm4j.smartbear.com) or the atlassian url (<mycontext>.atlassian.net).

      Michael