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,462,330
Community Members
 
Community Events
176
Community Groups

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

Atlassian Community Events