5

We recently upgraded to spring-cloud-starter-openfeign: 2.2.2 from version 2.0.0 and we encountered the following exception when calling the REST API that uses consumes and also having @RequestHeader Content-Type:

    feign.FeignException$UnsupportedMediaType: [415] during [POST] to [http://localhost:8080/test]
    [TestFeign#test(TestRequest,String)]: [{"timestamp":"2021-01-03T13:13:58.192+0000",
    "status":415,"error":"Unsupported Media Type",
    "message":"Invalid mime type \"application/json, application/json\": 
    Invalid token character ',' in token \"json, application/json\"","path":"/test"}] 

Our Feign Interface is defined as follows:
@RequestMapping(value = "/test",method = RequestMethod.POST,consumes= {"application/json"},
produces={"application/json"})
void test(@RequestBody TestRequest request,@RequestHeader("Content-Type") String contentType); 

We investigated and saw that in this case both values are being concatenated as follows:

Content-Type: "application/json, application/json"

When using spring-cloud-starter-openfeign:2.0.0 this issue does not occur.

Yuval Simhon
  • 1,439
  • 2
  • 19
  • 34

0 Answers0