Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

HTTP Code 500 when importing JUnit XML results into Xray REST endpoint

Edited

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

1 answer

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: Fine Software

Happy New Year, everybody! What better way to kick off 2022 than with a new Marketplace Partner Spotlight ✨ This month, we're getting to know Daniel Franz, co-founder of Fine Software. Fine Software ...

429 views 2 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you