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.
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.
Hi kathi we're you able to resolve this? I also having same issue. Kindly help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.