Xray Rest API call to import Test Execution Result

Ashish.Ranjan September 24, 2020

Hi,

I know this query has been answered in so many post but those have not helped me. I did research, and tried, but still facing issue in making an API call to import test execution result.

Approach I took:

  1. Created Test(Test Details: Cucumber), Test Precondition, Test Set, Test Plan and Test Execution
  2. Exported Test using "Xray - Export to Cucumber" option
  3. Added this in my BDD-Cucumber framework, executed and it has generated me cucumber.json file after execution

Trying API call using postman

Approach 1: /api/v1/import/execution/cucumber 

curl --location --request POST 'https://xray.cloud.xpand-it.com/api/v1/import/execution/cucumber' \
--header 'Authorization: Bearer $token’ \
--header 'Content-Type: application/json' \
--data-binary '@/Users/aranjan/Downloads/cucumber.json'

Error:

{ "error": "Error creating Test Execution - Team is required."}

Now, this means it is trying to create new instead of update existing 

Then, I used

Approach 2: /api/v1/import/execution/cucumber/multipart

curl --location --request POST 'https://xray.cloud.xpand-it.com/api/v1/import/execution/cucumber/multipart' \
--header 'Authorization: Bearer $token’ \
--form 'info=@/Users/aranjan/Downloads/xrayresultimport.json' \
--form 'result=@/Users/aranjan/Downloads/cucumber.json'

Error:

{ "error": "Unexpected field (result)"}

xrayresultimport.json

{
"fields": {
"project": {
"key": "HYP"
},
"customfield_10962": [
"Team","TeamQAAuto"
],
"issuetype": {
"id": "10722"
}
}
}

Approach 3: /api/v1/import/execution

curl --location --request POST 'https://xray.cloud.xpand-it.com/api/v1/import/execution' \
--header 'Authorization: Bearer $token’ \
--header 'Content-Type: application/json' \
--data-raw '{
    "testExecutionKey": "HYP-3313",
    "info" : {
        "startDate" : "2020-09-25T11:47:35+01:00",
        "finishDate" : "2020-09-25T11:53:00+01:00",
        "testPlanKey" : "HYP-3341"
    },
    "tests" : [
        {
            "testKey" : "HYP-3330",
            "start" : "2020-09-25T11:47:35+01:00",
            "finish" : "2020-09-25T11:50:56+01:00",
            "comment" : "Successful execution",
            "status" : "PASSED"
        }
     ]
}'
{ "error": "Error updating Test Execution - Issue update failed!"}

 Agenda:

I want to import the execution result in my existing Test Execution.

I request you to guide me here.

Thanks in advance.

2 answers

0 votes
Harish Ekambaram
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 6, 2023

There is still an alternative way to upload test results, which involves multiple cucumber JSON files. These JSON files contain an array of feature test results. Instead of uploading multiple files or merging them sequentially, you can merge the first array in all the test results to form a JSON file that contains an array of all the test results. After that, you can try to invoke the API to upload the test results. This will create a single test execution with all the test results from different feature files.

0 votes
Ashish.Ranjan October 4, 2020

@Bruno Conde @Sergio Freire - Xblend  Any suggestions here?

Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2020

@Ashish_Ranjan ,

the multipart endpoint always creates new Test Execution issues. The standard endpoint allows you to update an existing one or create new ones.

So, currently, there isn't a solution for updating results on an existing Test Execution while at the same time customize fields on the Test Execution.

 

Remember that you can always reach out Xray support and the team will support you throughout the issue you're facing and others.

Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2020

I would recommend also to vote on this suggestion related to this: https://jira.xpand-it.com/browse/XRAY-6221 

Ashish.Ranjan October 14, 2020

Thank you @Sergio Freire - Xblend for this insight.

 

the multipart endpoint always creates new Test Execution issues. The standard endpoint allows you to update an existing one or create new ones.

I have attempted this in my Approach 2. And for this also, I am getting error.

As updating card is not going to give me desired result, I wanted to work on multipart approach.It would be a great help if you let me know where am I going wrong with multipart approach.

 

the multipart endpoint always creates new Test Execution issues. The standard endpoint allows you to update an existing one or create new ones.

Updating card is falling for me as I have a custom field in the Test Execution issue type. Understood.

 

I have voted on the raised issue.

 

Thanks for your support.

Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 19, 2020

Hi @Ashish_Ranjan

You'll need to provide us more information so I recommend you reach out Xray support and the team will be glad to help you out.

 

Best Regards,

Sérgio.

Ashish.Ranjan October 19, 2020

Sure @Sergio Freire - Xblend .

I will write on Xray Support

abhishek shrivastava
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 7, 2023

@Ashish_Ranjan Was the issue resolved? Were you able to import the test results to JIRA? Can you please suggest the solution, which worked for you?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events