Hello i have been developing a python script to update Xray test on Jira using rest API BaseUrl/rest/raven/2.0/api/import/execution
however I have been receiving this error Error instantiating bean. Field(s) tests -\\u003e customFields -\\u003e name do not follow the correct format.
when i run the python script
url = "BaseUrl/rest/raven/2.0/api/import/execution"
personal_access_token = "******"
# Test execution JSON payload
test_execution = {
"testExecutionKey": "T4SV-T561",
"info": {
"revision": "1.0.42134",
"testEnvironments": [
"windows",
"Linux"
]
},
"tests": [
{
"testKey": "T4SV-T415",
"status": "PASS",
'executedBy':'*****@**.com',
"comment": "Test passed successfully",
"start": "2023-09-07T11:47:35+01:00",
"finish": "2023-09-07T11:50:56+01:00",
"customFields": [
{
"id": 1,
"name": "Name1",
"value": "[https://www.#.net"
},
{
"id": 2,
"name": "Name2",
"value": "https://www.#.net"
}]
}
]
}
headers = {"Content-Type": "application/json",'Authorization': 'Bearer ' + personal_access_token}
# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(test_execution),verify=False)
the POST request works fine with no errors if I remove the customfield
part from the JSON so I don't know in which format I should add the custom field because i got it exactly like that format from BaseURL/rest/raven/2.0/api/project/{ID}/settings/customfields/testruns
Just take out the name
attribute from the customFields
object. You need to use the id
instead, along with the value
.
See the following page for more info on the customFields object. That page also has the JSON schema of the Xray JSON format.
Your script would become something like:
url = "BaseUrl/rest/raven/2.0/api/import/execution"
personal_access_token = "******"
# Test execution JSON payload
test_execution = {
"testExecutionKey": "T4SV-T561",
"info": {
"revision": "1.0.42134",
"testEnvironments": [
"windows",
"Linux"
]
},
"tests": [
{
"testKey": "T4SV-T415",
"status": "PASS",
'executedBy':'*****@**.com',
"comment": "Test passed successfully",
"start": "2023-09-07T11:47:35+01:00",
"finish": "2023-09-07T11:50:56+01:00",
"customFields": [
{
"id": 1,
"value": "[https://www.#.net"
},
{
"id": 2,
"value": "https://www.#.net"
}]
}
]
}
headers = {"Content-Type": "application/json",'Authorization': 'Bearer ' + personal_access_token}
# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(test_execution),verify=False)