1

Getting 400 Error

2023-02-08T23:47:15.451+05:30  WARN 41316 --- [nio-8083-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity com.metafy.metafy.controller.UserController.deleteme(java.lang.String,java.lang.String,java.lang.String)]

Below is the Controller Code

@PostMapping("/deleteRoute")
    public ResponseEntity deleteme(@RequestBody String id, @RequestBody String route, @RequestBody String password) {
        return UserService.deleteRoute(id, route, password);
    }

Below is the Service Code

public ResponseEntity deleteRoute(String id, String route, String password) {
        ExamRoute getCurrentRoute = dynamoDBMapper.load(ExamRoute.class, id);
        String result = "Invalid Credentials";
        if(getCurrentRoute.getRoute().equals(route) && getCurrentRoute.getPassword().equals(password)) {
            // delete an item from the Routes table with id 32432
            result = getCurrentRoute.getId() + " is Deleted";
            dynamoDBMapper.delete(ExamRoute.builder().id(getCurrentRoute.getId()).build());
        }
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

Below is the Example Question

{
  "id": "user123",
  "route": "/example",
  "password": "securePassword"
}

enter image description here

invzbl3
  • 5,872
  • 9
  • 36
  • 76
  • Mention annotations `@produces` and `@Consumes` with your MediaType such as `application/json` , also while hitting from Postman, ensure, you are setting following headers , `accept: application/json` – Harsh Feb 09 '23 at 05:02

0 Answers0