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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,703
Community Members
 
Community Events
176
Community Groups

How to add Test Execution to a Test Plan with Xray Rest API?

Edited

I'm trying to add a Test Execution to a Test Plan using  Xray Rest API & Axios. I have already created an API key & authenticated successfully like so:


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}`))
   .catch(e => {
       throw new Error(e.response.data.error);
    });
};

Then, I made a call & passed some `param` values gathered before when creating a `Test Plan` & `Test Execution` like so:


await axios({
method: 'posts',
url: `https://xray.cloud.xpand-it.com/api/internal/testplan/${createdTestPlan.data.id}/addTestExecs`,
data: {
0: createdTestExecIssue.data.id,
},
});

However, I get this error:

(node:46352) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400. 

I was able to link a `Test Execution` to the `Test Plan` using another endpoint from Jira Rest API, but I'm looking to add it instead, check the screenshot below for reference. Any help will be appreciated!

Add-test-execution.png

1 answer

Hi @Manuel Suarez Abascal ,

you're using an internal API. You should use the public API for that, which is the GraphQL one.

Please have a look at this call.

 

Please note that if you want to do this association while importing test automation results, it would be possible depending on the REST API call you make. Further info here.

Regards,

Sergio

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS

Atlassian Community Events