0

We have two Microservice Services1 and Service2. In Service1 we have one PostMapping and return boolean value as below.

@PostMapping
public boolean reset(){
    return true
}

When consume from Service2 through restTemplate exchange method it will return in XML format as below.

boolean val = restTemplate.exchange(url, Post method, http entity with header, Boolean.class);

Output

<boolean>true</boolean>

we expecting in JSON format in resttemplate call and if try through postman it will return in JSON.

S. Anushan
  • 728
  • 1
  • 6
  • 12
  • Depending on the service that you’re calling, you may need to include an `Accept` header in the request to indicate that you want to receive json. Have you set one in your request? – Andy Wilkinson Jul 11 '21 at 09:48
  • If I add that I got 415 media not support error. – S. Anushan Jul 11 '21 at 09:52
  • 1
    That’s odd. What media type did you use? I’d check the headers of the request that Postman is sending, and adjust your code that’s using RestTemplate to match. – Andy Wilkinson Jul 11 '21 at 10:02

0 Answers0