I'm learning Spring-Boot features and also reviewing them with Postman. But when I run the code, I get a 400 bad request error in Postman like this: "Required request body is missing: public org.springframework.http.ResponseEntity." Have I missed any attributes or is the encoding completely wrong?
@RestController
@RequestMapping("/api/board")
@CrossOrigin
public class ProjectTaskController {
@Autowired
private ProjectTaskService projectTaskService;
@PostMapping("")
public ResponseEntity<?> addPTToBoard( @Valid @RequestBody ProjectTask projectTask, BindingResult result){
if(result.hasErrors()) {
Map<String, String> errorMap= new HashMap<>();
for(FieldError error: result.getFieldErrors()) {
errorMap.put(error.getField(), error.getDefaultMessage());
}
return new ResponseEntity<Map<String, String>>(errorMap, HttpStatus.BAD_REQUEST);
}
ProjectTask newPT= projectTaskService.saveOrUpdateProjectTask(projectTask);
return new ResponseEntity<ProjectTask>(newPT, HttpStatus.CREATED);
}
The projectTask code also has getters and setters.
@Entity
public class ProjectTask {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private long id;
@NotBlank(message = "summary cannot be blank")
private String summary;
private String acceptanceCriteria;
private String status;
public ProjectTask() {
}