亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Xray Rest API 將測試執行添加到測試計劃?

如何使用 Xray Rest API 將測試執行添加到測試計劃?

滄海一幻覺 2023-11-12 22:16:15
我正在嘗試使用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。我能夠使用 Jira Rest API 中的另一個端點鏈接到Test Execution,Test Plan但我希望添加它,請檢查下面的屏幕截圖以供參考。
查看完整描述

2 回答

?
茅侃侃

TA貢獻1842條經驗 獲得超21個贊

您可以使用 graphQL api 執行此操作,只需替換 YourTestPlanID 和 yourTestExecutionId 即可。


const response =  await axios({

    method: 'post',

    url:    'https://xray.cloud.xpand-it.com/api/v1/graphql',

    data:   { 

      query: 

        `mutation {

          addTestExecutionsToTestPlan(

            issueId: "YourTestPlanID",

            testExecIssueIds: ["yourTestExecutionId"]) {

                addedTestExecutions

                warning

            }

        }`

    },

    headers: { 

        Authorization:  `Bearer TOKEN obtained using the authentication api`,

        'Content-Type': 'application/json' }

});


查看完整回答
反對 回復 2023-11-12
?
德瑪西亞99

TA貢獻1770條經驗 獲得超3個贊

我能夠通過data像這樣傳遞不同的內容來解決這個問題:


await axios({

    ...

    ...

    data: [`${testExecutionId}`],

});

&X-acpt像這樣傳遞鍵/值對Request Header:


'X-acpt': `encodedCharaterGoesHere-YouNeedToretrievUsingNetworkTabInChrome`,

我的請求最終是這樣的:


await axios({

    method: 'post',

    url: `https://xray.cloud.xpand-it.com/api/internal/testplan/${testPlanId}/addTestExecs`,

    headers: {

      Accept: 'application/json',

      'Content-Type': 'application/json',

      'X-acpt': `encodedCharaterGoesHere-YouNeedToretrievUsingNetworkTabInChrome`,

      'X-Powered-By': 'Express',

    },

    data: [`${testExecutionId}`],

  });


查看完整回答
反對 回復 2023-11-12
  • 2 回答
  • 0 關注
  • 216 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號