How to import test execution results using REST API and XRay for JIRA

Hello,

I am trying to import test execution results for my project but am having difficulty associating tests with the test execution using the REST API. I have tried to emulate the instructions found at http://xray.xpand-it.com/display/XRAY/REST+API but it does not seem to be working. I can import a test execution without any associated tests.

Here is my request which I am posting to http://<URL>//rest/api/2/issue

"{""fields"": {""project"":{""key"": ""ET""}, ""summary"": ""Test execution"", ""description"":""Description"", ""issuetype"":{""id"":""10302""}, ""tests"":[{""testKey"" : ""ET-879"",""comment"" : ""Successful execution"",""status"" : ""PASS""},{""testKey"" : ""ET-880"",""comment"" : ""Execution failed"",""status"" : ""FAIL""},{""testKey"" : ""ET-881"",""comment"" : ""Successful execution"",""status"" : ""PASS""}]}}"

The "tests" field is not recognised, but I can't find the appropriate replacement to get this to work.

Any help you can give would be appreciated.

Thanks

Jamie

6 answers

1 accepted

Hi Jamie,

You must use the REST path specific to Xray: /rest/raven/1.0/import/execution

The JSON you are using is for the default REST service of JIRA. This will just create a Test Execution issue. 

If you follow the instructions on http://xray.xpand-it.com/display/XRAY/REST+API, it should be able to import the execution results by creating a new Test Execution issue, if you specify the "info" element (this will create a Test Execution issue in the same project where the Test issues are but we will soon release a new version where you can specify the project explicitly). You can update an existing test Execution if, instead of the "info" element you pass the "testExecutionKey": http://xray.xpand-it.com/display/XRAY/Import+Results

Have you already tried this REST path? Did you get an error?

HTH

Bruno Conde.

Hello,

Yes that was the first thing I tried, I've tried it again though and am still seeing problems. I'm now sending to http://<URL>/rest/raven/1.0/import/execution

My request is now

"{"info" : {"summary" : "Test execution trial","description" : "Blah"},"tests" : [{"testKey" : "ET-880","comment" : "Successful execution","status" : "PASS"},{"testKey" : "ET-881","comment" : "Successful execution","status" : "PASS"},{"testKey" : "ET-883","comment" : "Failed execution","status" : "FAIL"}]}"

But the response I am receiving is (HTML tags removed)

HTTP Status 406 - Not Acceptable
Not Acceptable
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers

As it appears that the issue is possibly with my "Accept" header I am also sending this

setRequestHeader "Accept", "application/json"

Please can you let me know if this is correct?

To be honest I'm new to Jira, XRAY, JSON and REST smile

Thanks for your help

 

 

Ok it seems that removing the setRequestHeader is actually working now. Thank you for your help Bruno.

Great. I was just about to send you an example by using curl: curl -H "Content-Type: application/json" -X POST -u admin:admin --data @data.json http://yourserver/rest/raven/1.0/import/execution where the "data.json" is your JSON file.

I am looking for the steps to Import Test cases to XRay Jira using REST API. I am looking for the JSON format I have to use to do the import. Can u help ?

Hi Bruno, Jamie,

I'm using XRAY for JIRA and I'm trying to import a JSON result via Import interface on Test Execution issue.
I've got some questions:

1) How can I import a cucumber JSON format? I've browsed online help and so on and I found that I should be able to export the JSON formatting it properly. But it doesn't work. I have a lot of unhandled exceptions without any possibility to understand what's wrong (java.lang.exceptions)


2) If I convert the test automatic results to XRAY JSON format, I can successfully upload them but I cannot see the EXAMPLES results (I've raised a request about it: https://support.atlassian.com/servicedesk/customer/portal/23/JST-155207)

Thanks,
Luca 

Is it possible to integrate selenium webdriver tests (in BDD style) with XRAY and Bamboo? Or is it only for cucumber test?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,307 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot