Identify whether an execution needs to be created or whether an existing one can be used
Asked by Dominik R?ther:

```
I need help with a small project i am running.

```

```
I have to see if there is a test on a certain date or not. But there should be a version for each day (e.g. November 9, 2020). That's what I'm supposed to find out with the help of a REST call.If it is not available, it must be created using a REST call.Input data:Date (e.g. November 9th, 2020)
```


Answers:
author: Sergio Freire - Xblend
body: HI [@Dominik R?ther](/t5/user/viewprofilepage/user-id/4141499) ,

1. what do you mean exactly with "see if there is a test on a certain date or not"? If it was created in that date? if it is scheduled to be run on that date? if it was modified on that date? Can you elaborate further please?
2. "there should be a version for each day" =\> what do you mean with this exactly?

Regards

S?rgio

comments: author: Dominik R?ther
body: HI [@Sergio Freire - Xblend](/t5/user/viewprofilepage/user-id/660760)

1. We have tests every day, and i have to see, if there is already an execution created for a certain day or not. if not, an execution should be created.

2. Since we have tests evry day, during a week, there must also be an execution for each day.

I hope it is a bit more clear now.

Regards

Dominik


author: Sergio Freire - Xblend
body: [@Dominik R?ther](/t5/user/viewprofilepage/user-id/4141499) ,

perhaps you can try to search for the Test Executions.

You can either use Jira's REST API and JQL for that or use Xray's GraphQL API, which in turn can also receive a JQL.

[https://xray.cloud.xpand-it.com/doc/graphql/gettestexecutions.doc.html](https://xray.cloud.xpand-it.com/doc/graphql/gettestexecutions.doc.html?)

In the JQL you can search for those issues but the exact query will depend on you you say that the Test Execution is aimed for a given day.

S?rgio


author: Sergio Freire - Xblend
body: [@Dominik R?ther](/t5/user/viewprofilepage/user-id/4141499) ,

perhaps you can try to search for the Test Executions.

You can either use Jira's REST API and JQL for that or use [Xray's GraphQL API](https://xray.cloud.xpand-it.com/doc/graphql/gettestexecutions.doc.html?), which in turn can also receive a JQL.

In the JQL you can search for those issues but the exact query will depend on you you say that the Test Execution is aimed for a given day.

S?rgio


author: Dominik R?ther
body: Hello Sergio,

I found the Problem. Here is the Rest call:

/rest/raven/1.0/api/testplan/{testplankey}/testexecution

Thanks for your help.

Dominik


author: Sergio Freire - Xblend
body: Gotcha, so you have a Test Plan and you wanted to find out the Test Executions of that Test Plan :)

All clear now? Do you need anything else?

Regards

S?rgio


author: Dominik R?ther
body: maybe a little thing, how can I create a test and give it different attributes such as the status?

So far I have had this order, but I am not getting anywhere.

POST /rest/raven/1.0/api/testexec/{testExecKey}/test

Thank you in advance

Dominik


author: Sergio Freire - Xblend
body: Well, that endpoint...

POST /rest/raven/1.0/api/testexec/{testExecKey}/test

... is to associate existing Tests to an existing Test Execution; it's not to create Tests.

More details here: <https://docs.getxray.app/display/XRAY/Test+Executions+-+REST>

However, that endpoint is for Xray on-premises (i.e. Jira server/Data Center).. and you are using Xray on Jira Cloud.. or not really?

Anyway, if you aim to \*create\* Tests, you have to use Jira's REST API for that and when doing so, you can define the values for standard fields your issues have.

The following open-source repository can be useful as it provides concrete examples of usage of Xray's APIs (for Jira server and for Jira Cloud) and also for Jira's REST API.

<https://github.com/Xray-App/xray-postman-collections>

Hope it helps.

Regards

S?rgio


author: Dominik R?ther
body: Hello Sergio,

thanks again, i figured it out.

But i have two more questions. I want to find out, with the helf of a REST call, which test cases are in a specific test plan.

I also want to find out, how i ca make a REST cal to attach test cases to a test run.

Would be very nice if you could help me again.

Kind regards

Dominik


author: Sergio Freire - Xblend
body: Hi [@Dominik R?ther](/t5/user/viewprofilepage/user-id/4141499) ,

I'm not sure if you're using Xray Cloud or Xray on jira premises? Can you please clarify?

Nevertheless, the Postman collections that I shared above provide examples for it.

Regards,

S?rgio


author: Dominik R?ther
body: Hi [@Sergio Freire - Xblend](/t5/user/viewprofilepage/user-id/660760)

Thank you, this has been very helpful. I have looked though the collection again and found some calls i need. Unfortunately, I couldn?t find the above-mentioned calls. Do you have an Idea?

I am using Xray on a lokal Server.

Regards,

Dominik


author: Sergio Freire - Xblend
body: Hi [@Dominik R?ther](/t5/user/viewprofilepage/user-id/4141499) ,

on your questions:

*I want to find out, with the helf of a REST call, which test cases are in a specific test plan.*

*I also want to find out, how i can make a REST call to attach test cases to a test run.*

1. getting the list of tests in a Test Plan
   1. please check [https://docs.getxray.app/display/XRAY/Test+Plans+-+REST](https://docs.getxray.app/display/XRAY/Test+Plans+-+REST%20) and use and HTTP GET /rest/raven/1.0/api/testplan/{testPlanKey}/test . This is in the Postman collection, under the "test plans" root folder.
2. A Test Run is an intance of a Test in the context of a Test Execution. Therefore, I guess you want to add Tests to a Test Execution instead. If that's the case, then please check: <https://docs.getxray.app/display/XRAY/Test+Executions+-+REST> . It's also in the Postman collection, under the "test executions" root folder.

Regards,

Sergio


Tags: cloud

rest

rest-api

xray