I am trying to sand post request using postman. for some reason i am getting 400 Bad Request - Required request body is missing. My controller is in spring boot environment.
My controller:
@RestController
public class HagarController {
@PostMapping(value = "/hagar")
@ResponseStatus(HttpStatus.OK)
public void hagar(@RequestBody String name, @RequestBody String id)
throws Exception{
System.out.println("my name is: " + name +" id: " + id);
}
}
Thanks!!
This is how I do it, I hope it will help you:
@RestController
public class HagarController {
@ResponseMapping(value = "/add", method = RequestMethod.POST)
public void hagar(@RequestBody String name, @RequestBody String id)
System.out.println("my name is: " + name +" id: " + id);
}
and in postman you probably added in Headers: see image : enter image description here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.