'Body not being displayed when response is 204
Locally when testing in postman I return my ID correctly but when I get to the case that I want to return a 204 status I return it but with no body message and can't seem to figure out why it's not displaying.
@PostMapping("/ID_values/")
fun getID(
@RequestBody
email: String
): ResponseEntity<String> {
return IDLookupService.lookupIDValue(email)
}
fun lookupIDValue(email: String): ResponseEntity<String> {
val message = "processing the email failed please check input"
logger.info(">>>processIDLookUpRequest")
Failures.failsafeRun {
IDRepo.findById(email)
}
val IDLookupResult = IDRepo.findById(email)
logger.info("<<<processIDLookUpRequest")
return if (IDResult.isPresent) {// this displays fine
ResponseEntity(IDResult.get().optValue.toString(), HttpStatus.OK)
} else {
return ResponseEntity(message, HttpStatus.NO_CONTENT)
//the message here is not being displayed
}
}
Solution 1:[1]
Your message is not being displayed because you are returning a NO_CONTENT http request. Change your https status to OK and you Will get yout message.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sixrandanes |
