Encountering "Error creating issues in Jira!" while trying to import JUnit XML to Xray

I’m facing an issue when attempting to upload my JUnit test results to Xray within JIRA. Whenever I go to import the XML file, it prompts an error message.

Here’s the XML test file I’m working with:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite name="login_page.spec.ts" timestamp="2025-01-21T08:15:32.405Z" hostname="firefox" tests="2" failures="1" skipped="0" time="12.847" errors="0">
  <testcase name="Login page ... Verify user login with valid credentials @smoke_test" classname="login_page.spec.ts" time="12.847"/>
</testsuite>

I made two attempts to upload this:

First attempt:

curl -v -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $AUTH_TOKEN" --data @"test_results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?projectKey=DEMO

Second attempt:

curl -v -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $AUTH_TOKEN" --data @"test_results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?testExecKey=DEMO-25&projectKey=DEMO

For my setup, DEMO represents the project key and DEMO-25 is the test execution ticket I created.

Both of these requests lead to the same error:

{
“error”: “Error creating issues in Jira!”
}

Can anyone suggest what might be causing this problem? I’m uncertain about what I could be missing in my setup.

This sounds like a permissions or project config issue. I’ve hit this before - the project had specific field requirements for test executions that weren’t getting filled during import. Check if your DEMO project has mandatory custom fields set up for Test Execution issue types. You can test this by manually creating a test execution in Jira to see what’s actually required. Also double-check your Bearer token scopes - it needs both read and write permissions for that specific project. Sometimes tokens work fine for other stuff but bomb out when creating new issues because of scope limits.

This usually happens because your XML structure is incomplete. You’ve got failures=“1” but no element inside the testcase to explain why it failed. Xray needs consistent data to create test executions properly. Either add a element if the test actually failed, or change it to failures=“0” if it passed. Also double-check that Xray’s configured correctly in your project and that auto-creation of test cases is enabled in your settings. I’ve seen this same issue when the XML has mismatched result data that Jira can’t turn into proper test execution issues.

had this same error just a bit ago. make sure ur auth token has the correct permissions for the project. also, consider adding a Content-Length header to your curl command - xray can be a bit picky with that stuff.