i am trying to send nested json object in POST request to my spring REST API.
Object java code
public class TestModel {
private String id;
private String name;
public TestModel(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}
Post method code in rest controller
@RequestMapping(value = "/helloPost")
public ResponseEntity<TestModel> helloPost(@RequestBody TestModel t) {
return new ResponseEntity<TestModel>(t, HttpStatus.OK);
}
My postman screenshot
It has to return status 200 ok and object i sent, but it returns 400 bad request permanently. Please, tell me what am i doing wrong. It was ok when i sent one string(my @RequestBody was string too) but completly not working with custom objects.
P.S i have added comma, no changes
