Hello all,
I'm having trouble importing JUnit test results using the Xray REST interface.
The test cases, test plan and a test execution were created beforehand.
For instructions on import I have followed this document: Importing Execution Results into Xray
The code that does this is written in Java and uses Spring Framework to build a REST client:
String encodedKey = Base64.getEncoder().encodeToString((restUser + ":" + pwd).getBytes());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.set("Authorization", "Basic " + encodedKey);
String xmlReport = readFile(path + "TEST-template.ExampleClassTest.xml", Charset.forName("UTF-8"));
RestTemplate restTemplate = new RestTemplate();;
HttpEntity<String> entity = new HttpEntity<>(xmlReport, headers);
ResponseEntity<String> response = restTemplate.exchange(xrayUri
+ "raven/1.0/import/execution/junit?projectKey=QSAVTEST&testExecKey=QSAVTEST-170",
HttpMethod.POST,
entity,
String.class);
As a result, I get the HTTP Code 500 Internal Server Error:
018-12-13 13:31:44,245 DEBUG [main] RestTemplate: Response 500 INTERNAL_SERVER_ERROR
Exception in thread "main" org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 null
at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:79)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:99)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:79)
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:777)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:735)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:578)
at template.SpringRestImporter.sendPost(SpringRestImporter.java:52)
at template.SpringRestImporter.main(SpringRestImporter.java:26)
Your help will be much appreciated.
Best regards,
Olga
Hi @Olga ,
I don't know exactly the details of the spring framework; however, we've made recently available an open-source project "xray-code-snippets" with some example for different languages.
You can see here some implementation examples for Java.
In your example, I suspect about the creation of the multipart element that needs to be named "file".
Regards
Sergio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.