Complete the code to return a ResponseEntity with status 200 OK.
return ResponseEntity.[1]().body("Success");
The ok() method creates a ResponseEntity with HTTP status 200 OK.
Complete the code to set the HTTP status to 404 NOT FOUND.
return ResponseEntity.status(HttpStatus.[1]).body("Not Found");
The NOT_FOUND status corresponds to HTTP 404.
Fix the error in setting a custom header in ResponseEntity.
return ResponseEntity.ok().header("[1]", "application/json").body(data);
HTTP headers are case-insensitive but conventionally use 'Content-Type' with capital letters.
Fill both blanks to create a ResponseEntity with status 201 CREATED and a Location header.
return ResponseEntity.status(HttpStatus.[1]).header("[2]", "/items/123").build();
The ResponseEntity.status(HttpStatus.CREATED) sets status 201, and the Location header tells where the new resource is.
Fill all three blanks to return a ResponseEntity with status 204 NO CONTENT, a custom header, and no body.
return ResponseEntity.[1]().header("[2]", "no-cache").[3]();
noContent() sets HTTP 204 status, Cache-Control is a header for caching, and build() completes the response without a body.