Using spring-mvc annotations, how can I define an @FeignClient that can POST form-url-encoded?
You must use FormEncoder in Feign encoder for url-form-encoded data in POST.
Include the dependency to your app:
Maven:
io.github.openfeign.form
feign-form
3.8.0
Add FormEncoder to your Feign.Builder like so:
SomeFeign sample = Feign.builder()
.encoder(new FormEncoder(new JacksonEncoder()))
.target(SomeFeign.class, "http://sample.test.org");
In the Feign interface
@RequestLine("POST /submit/form")
@Headers("Content-Type: application/x-www-form-urlencoded")
void from (@Param("field1") String field1, @Param("field2") String field2);
Ref for more info: https://github.com/OpenFeign/feign-form