I am making a XRAY REST API request from JEST to JIRA cloud as below,
https://adneurope.atlassian.net/api/v2/import/execution
I am also putting JSON Body containing execution results as below,
{
testExecutionKey: 'XAUTO-15',
info: {
summary: 'Execution of automated tests for release v1.3',
description: 'TEST!!!! This execution is automatically created when importing execution results from an external source',
version: 'Beta',
user: 'Anmol Fattepur',
revision: '1.0.42134',
startDate: '2014-08-30T11:47:35+01:00',
finishDate: '2014-08-30T11:53:00+01:00',
testPlanKey: 'DEMO-100',
testEnvironments: ['UAT'],
},
tests: [
{
testKey: 'XAUTO-4',
start: '2014-08-30T11:47:35+01:00',
finish: '2014-08-30T11:50:56+01:00',
comment: 'Successful execution',
status: 'PASSED',
},
],
}
It fails with response as below,
Symbol(Response internals)]: {
url: 'https://adneurope.atlassian.net/api/v2/import/execution',
status: 404,
statusText: 'Not Found',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
As I understand correctly you want to import Test Execution results in Jira Cloud
To import test execution results you would need to call the XRAY API, not the JIRA API
See the XRAY documentation:https://docs.getxray.app/display/XRAYCLOUD/REST+API
Also in documentation, you need to create an API token for the user who needs to execute the action.
Thanks for your response.
I have referred the XRAY API documentation and the provided REST API endpoint for importing Test Execution results in Jira Cloud is, /api/v2/import/execution
Using the same suggested endpoint.
However, I am still facing this error.
Please suggest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you used the following url to trigger the API:
https://xray.cloud.getxray.app/api/v2/import/execution
And you made yourself an API in Xray settings, https://docs.getxray.app/display/XRAYCLOUD/Global+Settings%3A+API+Keys ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc - Devoteam ,
Till now I was using below url to trigger the API:
https://adneurope.atlassian.net/api/v2/import/execution
And not the one you suggested. However, with little bit of exploration I understood we need to use https://xray.cloud.getxray.app/api/v2/import/execution and not the one above.
I have also created the API keys.
If possible can you please in brief explain the procedure to achieve my requirement?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Anmol Fattepur ,
The structure for the JSON request can be found here, based on the required format.
https://docs.getxray.app/display/XRAYCLOUD/Import+Execution+Results+-+REST+v2
So you need to use the Xray API to import test execution results.
You need an Xray API key for the user who is executing the JSON call
This user has to have a Jira account and Xray API as mentioned above and have the right permissions on the Jira project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc - Devoteam ,
I'm still struggling.
I will paste my complete code for your reference as below,
console.error
Error during test: FetchError {
message: 'invalid json response body at https://xray.cloud.getxray.app/api/v2/token reason: Unexpected token < in JSON at position 0',
type: 'invalid-json'
}
105 | await updateXRAY();
106 | } catch (error) {
> 107 | console.error('Error during test:', error);
| ^
108 | }
109 | });
110 |
at error (routes/ged.test.js:107:13)
at call (routes/ged.test.js:2:1)
at Generator.tryCatch (routes/ged.test.js:2:1)
at Generator._invoke [as throw] (routes/ged.test.js:2:1)
at asyncGeneratorStep (routes/ged.test.js:2:1)
at asyncGeneratorStep (routes/ged.test.js:2:1)
Appreciate if you can suggest a code fix?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I look at your input
And look at the Xray example
{
"testExecutionKey": "DEMO-1206",
"info" : {
"summary" : "Execution of automated tests for release v1.3",
"description" : "This execution is automatically created when importing execution results from an external source",
"version" : "v1.3",
"user" : "admin",
"revision" : "1.0.42134",
"startDate" : "2014-08-30T11:47:35+01:00",
"finishDate" : "2014-08-30T11:53:00+01:00",
"testPlanKey" : "DEMO-100",
"testEnvironments": ["iOS", "Android"]
},
"tests" : [
{
"testKey" : "DEMO-6",
"start" : "2014-08-30T11:47:35+01:00",
"finish" : "2014-08-30T11:50:56+01:00",
"comment" : "Successful execution",
"status" : "PASSED"
}
]
}
I highlighted the differences in BOLD (including, closing brackets) and you are using single quotes all over, as the need to be double or they are missing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc - Devoteam ,
Thanks for your response.
I have modified the code to match the input as suggested.
Pasting the entire code for your reference again,
console.error
An error occurred while getting the access token: Error: Failed to get access token: Unauthorized
at _callee8$ (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:57:13)
at call (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at Generator.tryCatch (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at Generator._invoke [as next] (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at asyncGeneratorStep (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at asyncGeneratorStep (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
61 | return responseData.access_token;
62 | } catch (error) {
> 63 | console.error('An error occurred while getting the access token:', error);
| ^
64 | throw error;
65 | }
66 | console.log('Response from token endpoint:', response);
at error (routes/ged.test.js:63:13)
at call (routes/ged.test.js:2:1)
at Generator.tryCatch (routes/ged.test.js:2:1)
at Generator._invoke [as next] (routes/ged.test.js:2:1)
at asyncGeneratorStep (routes/ged.test.js:2:1)
at asyncGeneratorStep (routes/ged.test.js:2:1)
console.error
Error during test: Error: Failed to get access token: Unauthorized
at _callee8$ (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:57:13)
at call (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at Generator.tryCatch (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at Generator._invoke [as next] (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at asyncGeneratorStep (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at asyncGeneratorStep (D:\nodejs\ADN_GED_Confluence\adn-ged-confluence\ged-confluence\routes\ged.test.js:2:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
126 | await updateXRAY();
127 | } catch (error) {
> 128 | console.error('Error during test:', error);
| ^
129 | }
130 | });
131 |
at error (routes/ged.test.js:128:13)
at call (routes/ged.test.js:2:1)
at Generator.tryCatch (routes/ged.test.js:2:1)
at Generator._invoke [as throw] (routes/ged.test.js:2:1)
at asyncGeneratorStep (routes/ged.test.js:2:1)
at asyncGeneratorStep (routes/ged.test.js:2:1)
I'm stuck, please suggest some solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc - Devoteam ,
I modified again as suggested.
Pasting entire code again for your reference,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Quick question,
Does your test and test execution already exist in Jira (XAUTO-25 and XAUTO-4)?
Or does only the Test (XAUTO-4) exists?
If the call is to create a new Test Execution you should use the following api call (example):
{
"info" : {
"summary" : "Execution of automated tests for release v1.3",
"description" : "This execution is automatically created when importing execution results from an external source",
"version" : "Beta",
"user" : "Anmol Fattepur",
"revision" : "1.0.42134",
"startDate" : "2014-08-30T11:47:35+01:00",
"finishDate" : "2014-08-30T11:53:00+01:00",
"testEnvironments": ["UAT"]
},
"tests" : [
{
"testKey" : "XAUTO-4",
"start" : "2014-08-30T11:47:35+01:00",
"finish" : "2014-08-30T11:50:56+01:00",
"actualResult" : "Successful execution",
"status" : "PASSED"
}
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But I see the following error:
An error occurred while getting the access token: Error: Failed to get access token: Unauthorized
So you are not authorised correctly, so this will cause the API call to fail.
SO there is something wrong in the call to authenticate yourself.
Could you first see if your authentication works?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.