I am trying to raise a feign client post request where I need to pass a JSON (multi-line text) and not a file. I am passing the content-type as multipart/form-data. And in my method, I am passing a POJO (containing all the fields that will be in the JSON) with @RequestPart annotation. And my builder has a SpringFormEncoder. But I am getting a 400 Bad Request in response. Can you please let me know what am I doing wrong here? Feign Client -
@RequestLine("POST /test")
@Headers({"Content-Type: multipart/form-data"})
void testmethod(@RequestPart(value="name") MyObject myobj);
Builder -
@Bean
public Encoder feignEncoder(){
return new SpringFormEncoder(new SpringEncoder(this.messageConverters));
}
And I want the json to be sent in this format - { "firstField": "field value", "secondField": "second value }