eddMX
08/07/2020, 6:10 PMasad.awadia
08/07/2020, 6:19 PMeddMX
08/07/2020, 6:19 PMasad.awadia
08/07/2020, 6:25 PM@RequestMapping(value = "/wells/{apiValue}", method = RequestMethod.GET)
public ResponseEntity<?> fetchWellData(@PathVariable String apiValue){
try{
OngardWell ongardWell = new OngardWell();
ongardWell = ongardWellService.fetchOneByApi(apiValue);
return new ResponseEntity<>(ongardWell, HttpStatus.OK);
}catch(Exception ex){
String errorMessage;
errorMessage = ex + " <== error";
return new ResponseEntity<>(errorMessage, HttpStatus.BAD_REQUEST);
}
}
asad.awadia
08/07/2020, 6:25 PM@RestController
is not appropriate for this. If you need to return different types of responses, use a ResponseEntity<?>
where you can explicitly set the status code.
The body
of the ResponseEntity
will be handled the same way as the return value of any @ResponseBody
annotated method.eddMX
08/07/2020, 6:28 PMeddMX
08/07/2020, 6:29 PMasad.awadia
08/07/2020, 6:30 PMeddMX
08/07/2020, 6:30 PMeddMX
08/07/2020, 6:30 PMeddMX
08/07/2020, 6:32 PM@RestController
@RequestMapping(value = [(Route.QUERIES)])
@Api(value = "DataQueryBuro", description = "API QUERY - V1", tags = ["DataQueryBuro"])
class BuroDataController : BuroDataInterface {
private val logger = LoggerFactory.getLogger(BuroDataController::class.java)
@Autowired
private lateinit var buroDataService: BuroDataService
@PostMapping
override fun getDataQueryBuro(@Valid @RequestBody body: BuroDataRequest): ResponseEntity<Any> {
<http://logger.info|logger.info>("--RPP-BURO-CREDITO-MS --getDataConsultationBuro --received request [{}]", body)
val buroResponse = buroDataService.getData(body)
return ResponseEntity.ok(buroResponse.toBuroDataCustomResponse()!!)
}
}
eddMX
08/07/2020, 6:33 PMeddMX
08/07/2020, 6:33 PMeddMX
08/07/2020, 6:34 PMTom Hermann
08/10/2020, 2:43 PM!!
, if that is nullable you need to properly handle it. I'd also double check your javax.validation constraints on your BuroDataRequest to make sure you are checking all your required fields.
The easiest way to troubleshoot this is to read your logs and see what is making the request fail.eddMX
08/10/2020, 3:26 PM