Jay
Jay

Reputation: 1356

Spring Boot Actuator /env endpoint returning data as XML - why?

We have several Spring Boot apps running as microservices. Each of them are running spring boot actuator to allow us to monitor /metrics, /env, /health, etc. On just one of these services the /env endpoint is returning data as XML when requested in the browser. Further, the XML is invalid, but what I really care about is getting the endpoint to return data in json. The reason the XML is invalid is because we are using Spring Cloud Config and the first element contains the GitHub URL which makes it invalid.

<LinkedHashMap xmlns=""><profiles>development</profiles><configService:https://github.com/ourcompany/configs/usage.yml>

I can not find anything different about this one project that would allow the data to be returned in json.

If I use cURL and pass an Accept header with value = application/json the service will correctly return json, but why is the browser returning XML? What I also noticed with this service is that I can pass Accept = application/xml and get it to return XML, but my other services return a 406 Not Acceptable response when requesting XML. Strange.

We are using spring-boot-starter-parent version 1.2.2.RELEASE as well as using spring-cloud-starter 1.0.0.RELEASE.

Upvotes: 3

Views: 1811

Answers (1)

Jay
Jay

Reputation: 1356

ci_'s comment above is what is happening. Having an XmlMapper caused the actuator endpoints to return XML. Hitting the /env.json endpoint will solve the issue for me.

Upvotes: 4

Related Questions