I am trying to integrate some junit xml results in to my JIRA/Xray test run. I have created the simplest result.xml
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite name="account_settings.spec.ts" timestamp="2025-01-21T05:39:49.602Z" hostname="chromium" tests="1" failures="0" skipped="0" time="9.129" errors="0">
<testcase name="Account settings ... Edit Account details of a admin user @account_detail" classname="account_settings.spec.ts" time="9.129"/>
</testsuite>
The call I am making to publish (Import Execution Results - REST, as per xray documentation) is follows... Try 1:
curl -v -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $TOKEN" --data @"results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?projectKey=PRJ
Try 2:
curl -v -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $TOKEN" --data @"results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?testExecKey=PRJ-16&projectKey=PRJ
Here PRJ is my Jira project that has Xray integrated. PRJ-16 is my "Test Execution" ticket which contains one test in it.
The response for this comes in as
{ "error": "Error creating issues in Jira!" }
What am I dong wrong here?
The error returned by the API doesn't provide much details but we can can provide some clues to what may be causing it.
Xray cloud API will internally invoke Atlassian APIs to create Test and Test Execution issues. Sometimes that may fail because the user for whom you created the Xray API key credentials (client id + client secret) is not allowed to create those issue types on the target Jira project. This happens frequently.
Also, sometimes Jira/project administrator add required fields for those issue types on the target Jira project, which will lead to a failure if we try to create them without specifying values for those fields.
Therefore, the recommendation would be as follows: