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

Originally posted by lokessri on August 18, 2021

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

Originally posted by josh42 on August 30, 2021

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. :wink:

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

…/jira/rest/tests/1.0/testcase//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/?fields=id

Hope, this helps.

Cheers

Josh

Originally posted by sonya_m on September 06, 2021

Great advice josh42!

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

Originally posted by lokessri on September 06, 2021

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

Originally posted by lokessri on September 06, 2021

josh42/ sonya_m , tagging you both so that your notified

Originally posted by josh42 on September 06, 2021

If you stick to GET calls, you’ll be fine in terms of breaking stuff with the calls themselves. But as I mentioned, you should check for any undocumented API changes (in a staging environment) before upgrading to a newer version of ZS, so your automation does not suddenly break down.

I don’t think, that the load should be a problem, but it depends on your infrastructure. When in doubt, test it out (sorry :P). Just do a quick load test and you’ll see, what’s what.

Side note: There are, of course, also a lot of internal PUT/POST endpoints and these can be quite dangerous. I once accidentally removed all priorities and statuses from a project. :grinning_face_with_smiling_eyes:

Originally posted by egvozdev on January 20, 2022

Hello,

Would you please advice what exact endpoint I should use? i.e. for example

https://jira.com/jira/rest/tests/1.0/testcase/1558/testresults?fields=key,testRun

or

https://jira.com/rest/atm/1.0/testcase/1558/testresults?fields=key,testRun

Both returns 404 :disappointed_face:

I use Jira server 8.13.3 and Zephyr scale 8.7.2

Also - I didn’t get test id with request …/testcase/TT-T3?fields=id - got empty {}, so I used Test script id instead (1558) - is it correct?

Thank you

Evgeny

Originally posted by egvozdev on January 20, 2022

Sorry guys, I found the answer and my mistakes. All works as described -

I had to use internal API ../rest/tests/… for getting internal test id and then again internal API for getting all executions, using internal test id as described! :slightly_smiling_face:

Originally posted by Michael_Timpe on April 08, 2024

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 (.atlassian.net).

Michael

Originally posted by Megha1 on August 13, 2026

Hi did you get a solution for this? we tried with jira and zephyr access token but it is not working