Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Failed to import test execution results. Status code: 400 Response: {"error":"Error creating issues

I have written the following python code:

import requests
import json
import os

xray_cloud_base_url = "https://xray.cloud.getxray.app/api/v2"
client_id = provided
client_secret = provided

# endpoint doc for authenticating and obtaining token from Xray Cloud: https://docs.getxray.app/display/XRAYCLOUD/Authentication+-+REST+v2
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
auth_data = { "client_id": client_id, "client_secret": client_secret }
response = requests.post(f'{xray_cloud_base_url}/authenticate', data=json.dumps(auth_data), headers=headers)
auth_token = response.json()
with open('sample.xml', 'r') as file:
junit_xml_content = file.read()

# Prepare headers
headers = {
'Authorization': 'Bearer ' + auth_token,
'Content-Type': 'application/xml',
'X-Info-JSON': json.dumps({
"fields": {
"project": {
"key": "DX"
},
"summary": "Test Execution for JUnit tests",
"description": "This contains test automation results",
"components": [{"name": "QA"}],
"issuetype": {
"name": "Test Execution"
}

# "fixVersions": [{"name": "v1.0"}]

}
})
}
url = f'{xray_cloud_base_url}/import/execution/junit?projectKey=DX&testExecKey=DX-79900'
response = requests.post(url, headers=headers, data=junit_xml_content)

# Send the POST request
# response = requests.post(f'{xray_cloud_base_url}/import/execution/junit', headers=headers, data=junit_xml_content)

# Process the response
if response.status_code == 200:
print('Test execution results successfully imported.')
else:
print(f'Failed to import test execution results. Status code: {response.status_code}')
print(f'Response: {response.text}')
Error:

Failed to import test execution results. Status code: 400
Response: {"error":"Error creating issues in Jira! - components: Components is required."}

I have given the right component name as i have matched with JIRA ticket.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events