Error in Xray Rest API call for importing Test Execution Result

5.1k views Asked by At

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

/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

/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"
}
}
}

/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.

1

There are 1 answers

0
Sérgio On

Currently, if you use the multipart endpoint it will always create new Test Executions. The multipart request has a minor typo: you should have "results" instead of "result". An example would be something like this:

curl -H "Content-Type: multipart/form-data" -X POST -F [email protected] -F [email protected] -H "Authorization: Bearer $token" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber/multipart

That should make it work :)

Note: concerning the last example you gave, there could be several causes for it, including restrictions on Jira side. That would be analyzed by the Xray support team.