How AI is applied across API Evangelist and APIs.io. Read my AI disclosure →
API Evangelist API Evangelist
Discovery
Learnings
Guidance
Toolbox
Alignment
API Evangelist LLC

Java Spring Boot response entity with map

calendar_today May 30, 2026 person mikelauskas domain spring-boot

I have the following code that creates a ResponseEntity for the response of a Spring app. Is there any more efficient way of doing this method? @GetMapping(“/api/payments/reservation/{idReservation}”) public ResponseEntity > obtenerPagoReal(@PathVariable(“idReservation”) int idReservation) { Payment pay = dao_interface.findByIdReserva(idReservation); Map response = new HashMap<>(); if (pago!=null) { response.put(“status”, “success”); response.put(“code”, 200); response.put(“message”, “Payment done”); response.put(“data”, pay); return ResponseEntity.ok(response); } else { response.put(“status”,

open_in_new Read original post