Spring-cloud-netflix: Eureka Server Not Using Content-Type

Created on 15 Jul 2015  路  2Comments  路  Source: spring-cloud/spring-cloud-netflix

When trying to use the REST API, the content-type header does not change the response format and always returns an xml body. According to the Eureka documentation for the REST API, specifying the content type should allow for JSON responses: https://github.com/Netflix/eureka/wiki/Eureka-REST-operations

// Both of these requests return an xml response
curl http://localhost:8761/eureka/apps -H "Content-Type:application/json;charset=UTF-8"
curl http://localhost:8761/eureka/apps -H "Content-Type:application/json"
question

Most helpful comment

Yo, @ngourley , I've struggled myself yesterday with this issue. Apparently you need to also specify the Accept header in order to get the json response.

curl http://localhost:8761/eureka/apps -H "Content-Type:application/json" -H "Accept:application/json"

All 2 comments

Yo, @ngourley , I've struggled myself yesterday with this issue. Apparently you need to also specify the Accept header in order to get the json response.

curl http://localhost:8761/eureka/apps -H "Content-Type:application/json" -H "Accept:application/json"

This is pretty standard content-negotiation (also it is controlled entirely within Netflix code, so we couldn't change it here if we wanted to).

Was this page helpful?
0 / 5 - 0 ratings