I have a source which calls a post api and the request is url encoded. How can I retrieve the request data that is url encoded using spring boot.
In my controller I have below method,
@PostMapping(value = "/res", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public Map<String, Object> postResponse(@RequestBody Map<String, Object> url) {...}
It returns error
"error": "Unsupported Media Type", "message": "Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"
How can I get form-urlencoded data in controller
I got the answer finally.
url encoded values can be read as String
@PostMapping(value = "/res", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public Map<String, Object> postResponse(@RequestBody String request) {...}