I am using @RestController
s with an application where all requests are POST
requests ... As I learned from this post , you can't map individual post parameters to individual method arguments, rather you need to wrap all the parameters in an object and then use this object as a method parameter annotated with @RequestBody
thus
@RequestMapping(value="/requestotp",method = RequestMethod.POST)
public String requestOTP( @RequestParam(value="idNumber") String idNumber , @RequestParam(value="applicationId") String applicationId) {
return customerService.requestOTP(idNumber, applicationId);
will not work with a POST
request of body {"idNumber":"345","applicationId":"64536"}
MY issue is that I have A LOT of POST
requests , each with only one or two parameters, It will be tedious to create all these objects just to receive the requests inside ... so is there any other way similar to the way where get request parameters (URL parameters) are handled ?