Search code examples
javaspringnetflix-feign

Setting the media type when using @RequestLine


I am using @RequestLine annotatin in my Feign Client interface. It only takes the Request Method and Path, is there a way to set the media type it produces and consumes?

This is what I have, any suggestions what ways I can add the media type it produces and consumes to this?

@RequestLine("POST /metrics-service/rest/addMetric")
    MyEntity sendEntity(@RequestBody MyEntity toSend);

Solution

  • Yes, very simple, you can add

    @Headers("Content-Type: application/json")
    

    check out the reference: https://github.com/Netflix/feign