Based on multiple thread regarding topic "'application/x-www-form-urlencoded' not working with @RequestBody" I haven't been successful in finding a solution for WebFlux Spring application.
I have a WebFlux Controller method:
@PostMapping(value = "/endpoint", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public Mono<AddRecipientResponse> createRecipient(@RequestBody
final MultiValueMap<String, String> formData,
@RequestHeader
final Map<String, String> headers) {
But when I post my reqest I'm getting this error:
Could not resolve parameter [0] ... RecipientController.createRecipient(long,org.springframework.util.MultiValueMap<java.lang.String, java.lang.String>,java.util.Map<java.lang.String, java.lang.String>): 415 UNSUPPORTED_MEDIA_TYPE
Most of the solution rely on replacing @RequestBody
with @RequestParam
. However this cannot apply for my case. I need to have both @RequestBody
and consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE
. I tried following steps described in following threads, but off of them are for Spring MVC.
https://stackoverflow.com/a/70148328/18734587
https://stackoverflow.com/a/51160620/18734587
Have anyone figured out how to solve 415 UNSUPPORTED_MEDIA_TYPE error for a request with MediaType.APPLICATION_FORM_URLENCODED
and @RequestBody
for a WebFlux application?
Quoting this answer here
I find it to be absolutely spot-on.