We have a scenario where a POST application/form-url-encoded request is to be sent to an API endpoint. And we are using @FeignClient annotated interface having a @PostMapping annotated function which takes in a POJO class as an argument such that the attributes of the class will be set as key value pairs of form data.

The issue is that the POJO class ( which is an argument to the function ) is derived from a base class. Due to which the form data posted to the API endpoint does not contain the attributes of the base class.

It works fine if the argument to @PostMapping function is a simple POJO class which doesn't extend any other class.

Can you please suggest a solution to the issue?

Comment From: kdavisk6

@techestop4u

When using the Spring extensions, a custom Encoder is registered that is responsible for dealing with bean driven parsing. I recommend checking in with Spring Cloud OpenFeign on Stack Overflow first.

If that doesn't pan out, Feign has a special library for dealing with forms, feign-form that may help you.

Comment From: DidierLoiseau

Just coming across this at random, but note that Spring Cloud OpenFeign depends on feign-form. The encoding is performed by feign-form’s PojoUtil, which relies on type.getDeclaredFields(), so it won’t retrieve parent fields.

It also presents some other strange quirks, such as ignoring final fields, see OpenFeign/feign-form/issues/77

(maybe this issue should be moved to feign-form?)

Comment From: khe817

Any update for this?

It would be nice if feign form can also encode properties from base/super classes. As @DidierLoiseau said, type.getDeclaredFields() in PojoItil won't do it. I know for a fact that it used to do that. We used to be no issues with inherited properties and nested classes until 2 years ago.

Thank you!