我正在尝试使用Xray Rest API和Axios将测试执行添加到测试计划中。我已经创建了一个 API 密钥并成功通过了身份验证,如下所示:
const axios = require('axios');
const { argv } = require('yargs');
const { clientId, clientSecret } = argv;
const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
};
const authenticateXray = async () => {
await axios({
method: 'post',
url: `https://xray.cloud.xpand-it.com/api/v2/authenticate`,
headers,
data: {
client_id: clientId, // my created client id goes here
client_secret: clientSecret, // my created client secret goes here
},
})
.then(res => console.log(`Xray authentication response status was: ${res.status}`)) // 200!
.catch(e => {
throw new Error(e.response.data.error);
});
};
然后,我打电话并传递了一些param
在创建Test Plan
&之前收集的值,Test Execution
如下所示:
await axios({
method: 'posts',
url: `https://xray.cloud.xpand-it.com/api/internal/testplan/${createdTestPlan.data.id}/addTestExecs`,
data: {
0: createdTestExecIssue.data.id,
},
});
但是,我收到此错误:(node:46352) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
. 我能够将 a 链接Test Execution
到Test Plan
使用 Jira Rest API 的另一个端点,但我希望添加它,请查看下面的屏幕截图以供参考。