I'm trying to understand the behaviour of an HTTP DELETE request.
On my java web application, I defined the following
@DeleteMapping("url/route")
public ResponseEntity<String> route(@RequestParam int param1, @RequestParam long param2, @RequestParam long param3, @RequestParam String param4) {
System.out.println(param1 + "-" + param2 + "-" + param3 + "-" + param4 );
return new ResponseEntity<String>(HttpStatus.OK);
}
@DeleteMapping("url/route2")
public ResponseEntity<String> route2(@RequestBody String body) {
System.out.println(body);
return new ResponseEntity<String>(HttpStatus.OK);
}
And on a java client, I do the following
public final void myFunction(final int param1, final long param2, final long param3, final String param4) {
restTemplate.delete("http://localhost:8090/url/route?"
+ "param1=" + param1 + "&"
+ "param2="+ param2 + "&"
+ "param3=" + param3 + "&"
+ "param4=" + param4, String.class);
restTemplate.delete("http://localhost:8090/url/route2", "SomeText", String.class);
}
The first request works fine, the log is well displayed. However, on the second case, i get the following error
HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity<java.lang.String> com.thales.atm.thmi.microservice.CanvasController.deleteGraphicObject2(java.lang.String)]
I use the module spring-boot-starter-web of spring boot (v2.7.1 on my project).
Can someone explain me what's wrong in my ussage of body parameters for this delete request ?
Thanks!