Use the rest api to get test summary results when not in folders

Mary Courtney November 15, 2019

Have been successful in using the rest api to get summary of execution results:

 

http://localhost:2990/jira/rest/zapi/latest/cycle/cycleId/folders?projectId=&versionId=&limit=&offset=

However, the way that my organisation has organised things is to have put most of the data into cycles, without putting them into folders. 

 

e.g. 

Version 1 

> cycle 1

> cycle 2

    > > folder 2a 

    > > folder 2b

I can get results for folder 2a/2b etc, but not for cycle 1 as it doesn't have any sub-folders. But I can see the results in jira

zephyr_folders.PNG

I've done my best to download the data using: 

http://localhost:2990/jira/rest/zapi/latest/cycle?projectId= 

 

but it's only by downloading each and every execution and the result of it that I'm able to get this data. It'd be very good if I could get the summary for the cycle, just like I can for folders, with a roll up of pass and fail results. Is this possible? If so how? 

3 answers

0 votes
GANESHATHMAGNANAM April 9, 2020

can someone help pls,

I have installed the Jira locally in my machine and also installed the Zephyr, ZAPI for testing the usage of the rest api updating the Jira test cases.

But whenever i run the localhost:8282 APIs i am getting "Dead link" message in the postman. What is that i am missing here?

Below is what i am using?

http://localhost:2990/jira/rest/zapi/latest/systemInfo

Response:

 <title>Oops, you&#39;ve found a dead link. - JIRA</title>

0 votes
Cash_Best December 3, 2019

For what it's worth, I am trying to accomplish the opposite and I believe you've helped me figure out how to get results from cycle folders.  So thank you for that :)

As far as what you're trying to do, I was able to accomplish it like this:

1. get a dictionary/json map of cycle ids of your project with this request:

http://localhost:2990/rest/zapi/latest/cycle?projectId=<your-project-id>

...each entry in the map is a cycle, just find the entry with the "name": "cycle 1" key/value and that entry number is your cycle id.  An example would look like this:

"2": <-- this is your cycle id
{
"totalExecutions":0,
"endDate":"",
"description":"test cycle for release 1.0",
"versionName":"testRelease-1.0",
"sortQuery":"ID:DESC",
"projectKey":"TES",
"totalDefects":0,
"isTimeTrackingEnabled":true,
"action":"expand",
"modifiedBy":"JIRAUSER10000",
"executionSummaries":
{
"executionSummary":[]
},
"soffset":"0",
"totalExecuted":0,
"started":"",
"isExecutionWorkflowEnabledForProject":true,
"expand":"executionSummaries",
"versionId":10000,
"environment":"",
"createdDate":"2019-12-02 09:13:06.221",
"totalCycleExecutions":2,
"build":"",
"createdBy":"sqa",
"ended":"",
"name":"cycle 1", <-- look for this key/value to match desired cycle
"totalFolders":0,
"projectId":10000,
"createdByDisplay":"admin",
"startDate":""

 2. use fetched cycle id to get execution ids for that cycle:

http://localhost:2990/rest/zapi/latest/execution/?action=expand&cycleId=<fetched-cycle-id>

 ...this will return a map of execution data.  Here, under the "executions" key, you can find each test case in that cycle, each of which having an "id" key.  Should look something like this:

"executions":
[
{
"id":4, <-- execution id
"orderId":4,
"executionStatus":"2", <-- pass/fail value
"executionWorkflowStatus":"CREATED",
"executedOn":"02/Dec/19 4:08 PM",
"executedOnVal":1575331682407,
"executedBy":"sqa",
"executedByDisplay":"admin",
"comment":"",
"htmlComment":"",
"cycleId":2, <-- should match your fetched cycle id
"cycleName":"cycle 1", <-- should match your cycle name from earlier
"versionId":10000,
"versionName":"testRelease-1.0",
"projectId":10000,
...},
...],
...}

 if you want to dig further (perhaps each test case has step results you'd like to see) you can use execution id to get step results for that test case:

http://localhost:2990/rest/zapi/latest/stepResult?executionId=<fetched-execution-id>

 I hope this helps :)

0 votes
Cash_Best December 3, 2019

For what it's worth, I am trying to accomplish the opposite and I believe you've helped me figure out how to get results from cycle folders.  So thank you for that :)

As far as what you're trying to do, I was able to accomplish it like this:

1. get a dictionary/json map of cycle ids of your project with this request:

http://localhost:2990/rest/zapi/latest/cycle?projectId=<your-project-id>

...each entry in the map is a cycle, just find the entry with the "name": "cycle 1" key/value and that entry number is your cycle id.  An example would look like this:

"2": <-- this is your cycle id
{
"totalExecutions":0,
"endDate":"",
"description":"test cycle for release 1.0",
"versionName":"testRelease-1.0",
"sortQuery":"ID:DESC",
"projectKey":"TES",
"totalDefects":0,
"isTimeTrackingEnabled":true,
"action":"expand",
"modifiedBy":"JIRAUSER10000",
"executionSummaries":
{
"executionSummary":[]
},
"soffset":"0",
"totalExecuted":0,
"started":"",
"isExecutionWorkflowEnabledForProject":true,
"expand":"executionSummaries",
"versionId":10000,
"environment":"",
"createdDate":"2019-12-02 09:13:06.221",
"totalCycleExecutions":2,
"build":"",
"createdBy":"sqa",
"ended":"",
"name":"cycle 1", <-- look for this key/value to match desired cycle
"totalFolders":0,
"projectId":10000,
"createdByDisplay":"admin",
"startDate":""

 2. use fetched cycle id to get execution ids for that cycle:

http://localhost:2990/rest/zapi/latest/execution/?action=expand&cycleId=<fetched-cycle-id>

 ...this will return a map of execution data.  Here, under the "executions" key, you can find each test case in that cycle, each of which having an "id" key.  Should look something like this:

"executions":
[
{
"id":4, <-- execution id
"orderId":4,
"executionStatus":"2", <-- pass/fail value
"executionWorkflowStatus":"CREATED",
"executedOn":"02/Dec/19 4:08 PM",
"executedOnVal":1575331682407,
"executedBy":"sqa",
"executedByDisplay":"admin",
"comment":"",
"htmlComment":"",
"cycleId":2, <-- should match your fetched cycle id
"cycleName":"cycle 1", <-- should match your cycle name from earlier
"versionId":10000,
"versionName":"testRelease-1.0",
"projectId":10000,
...},
...],
...}

 if you want to dig further (perhaps each test case has step results you'd like to see) you can use execution id to get step results for that test case:

http://localhost:2990/rest/zapi/latest/stepResult?executionId=<fetched-execution-id>

 I hope this helps :)

Cash_Best December 3, 2019

Oops! My answer got posted twice, sorry about that :)

Saneeya Emad January 30, 2022

The ZAPI is not using more, how can i get id's through SmartBear? anyone can help me

Saneeya Emad January 30, 2022

Not able to access above links, anyone here who can guide me?

Suggest an answer

Log in or Sign up to answer