Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Snippet of XRAY Rest API Test Results

Kathi Paquet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2018

I am trying to find a snippet of code on how to call the Rest API.  I already have my tests results writing to a cucumber.json file.  Now I need to upload after the test runs.  I am having trouble where to place the code.

curl -H "Content-Type: application/json" -X POST -u admin:admin --data @cucumber_output.json http://yourserver/rest/raven/1.0/import/execution/cucumber 

Or even this method 

public static void exportReportToJIRA(String username, String password, String jiraURL, String reportFilePath) {

String[] command = {"curl.exe", "-D-", "-X", "POST", "-H", "Content-Type: application/json",

"-H", "Authorization: Basic " + encodeBase64String(username + ":" + password),

"--data", "@" + reportFilePath,

jiraURL + "/rest/raven/1.0/import/execution/cucumber"

};

 

ProcessBuilder process = new ProcessBuilder(command);

Process p;

 

do {

System.out.println("\ninfo: Checking if cucumber.json file has been generated\n");

try {

Thread.sleep(1000);

} catch (InterruptedException ex) {

Thread.currentThread().interrupt();

}

} while (!fileExists(reportFilePath));

 

try {

System.out.println("\ninfo: Starting process that accepts curl POST command\n");

p = process.start();

} catch (IOException e) {

System.out.print("\nerror: Tried to execute curl command that posts json file to JIRA Xray, something went wrong\n");

e.printStackTrace();

}

}

 

Does this go in the Runner class? Or does someone have an example I can look at.

3 answers

0 votes
jagannathan santhanasamy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 14, 2020

Hi Kathi,

cloud_auth.json - Could you please help me to figure out JSON format to store client id and secret id?

Is it something like this?

{

client_id : "",

secret_id : ""

}

 

Thanks in advance.

0 votes
Smriti Ajit April 16, 2019

Hi kathi we're you able to resolve this? I also having same issue. Kindly help

Kathi Paquet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2019

I needed to create an authentication key:

https://confluence.xpand-it.com/display/XRAYCLOUD/Global+Settings%3A+API+Keys

Then create a json with the client id and client service id

I saved as cloud_auth.json run the curl command below:

curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v1/authenticate 

 

Then set the token with the variable or command

Set the token with the below command or as a variable 

set_token=”<insert the token with the params>” 

To set as variable type this: 

token=$(curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v1/authenticate| tr -d '"') 

Run command curl -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $token"  --data @"data.xml" https://xray.cloud.xpand-it.com/api/v1/import/execution/junit?projectKey=XTP 

This Adds new test and execution 

Like Jithin MJ likes this
Mareke
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 28, 2020

copied from Atlassian site...

0 votes
Inês Silva
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 21, 2018

Hi Kathi,

We need some more details, so please contact directly our support service desk: https://jira.xpand-it.com/servicedesk/customer/portal/2
We'll be glad to help.

Thank you,
The Xray team

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events