I tried to create some code :
@RequestMapping(value = "/testing", method = RequestMethod.POST) public ResponseEntity<Object> testing(@RequestParam(value = "requestId", required = true) String requestId){ return new ResponseEntity<Object>(requestId, HttpStatus.OK); } And I test that service using postman the response is success, no issue But when I change the RequestMethod to DELETE
@RequestMapping(value = "/testing", method = RequestMethod.DELETE) public ResponseEntity<Object> testing(@RequestParam(value = "requestId", required = true) String requestId){ return new ResponseEntity<Object>(requestId, HttpStatus.OK); } Response of that service is error :
{ "trace": "org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'requestId' is not present\r\n\tat org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:204)\r\n\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:112)\r\n\tat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument I set the requestId on body (form-data) same like i did when i call the POST method. I only change the RequestMethod from POST to DELETE, any idea for this case?
RequestParamextracts the value from URI, not the body form-data