[ad_1]
Based on the answer from: Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported for @RequestBody MultiValueMap
I’m have write post method:
@PostMapping (value = "test_3d_gmo", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public ResponseData<String> returnUrlCall(@RequestParam Map<String, String> param, MultiValueMap<String, String> body) {
LOGGER.info("request param {}", param.toString());
LOGGER.info("request body {}", body.toSingleValueMap());
ResponseData<String> res = new ResponseData<>();
res.setAppData("Test");
return res;
}
I’m send request to this API using postman:
curl --location --request POST 'localhost:8080/api/cc/test_3d_gmo?message=a' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'param1=g1' \
--data-urlencode 'param2=g2' \
--data-urlencode 'param3=g3'
But my body always missing, param and body only have query string message. How i can fix this ?
[ad_2]