I want to use Feign client in my project but some endpoints produces text/plain
while consuming application/json
. Right now I have something like this. Method is producing plain/text
and will consume application/json
. Is there a way to fix it? Note that this is not a Spring boot application. It's just a Java/Maven project.
@Headers("Content-Type: text/plain")
@RequestLine(value = "POST /containers/{id}/services")
String startService(@Param("id") String id, String serviceType);
In Jaxrs we use below headers to specify the mime types that this method or class uses.
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.TEXT_PLAIN)
I want to be able to do same thing but there is no Produces or consumes headers in feign client. There is only @Headers there you can specify content type. I wonder if this annotation's Content-Type
is used for both consuming and producing, or just for consuming, or if you can specify different types for both producing and consuming?
@Headers content should look like this:
With
Accept
header in place, you tell feign client to produceJSON
(in your case it isserviceType
passed into the method) and consumetext/plain
.