Issue
I have a spring api endpoint that looks like this:
public ResponseEntity<TestObj> getCounterProposals(
@PathVariable Long testObjId, @RequestBody(required = false) Boolean status)
How do I send a request so that the status parameter gets filled up. My endpoint looks like this:
GET /api/test/{testId}
Right now its value is always null and the testId is populated. I send the request from Postman like this:
Should I wrap the Boolean into some DTO object?
Solution
Since - as other people mentioned - having a body with a GET
request is not conventional.
If your requirement is to use @GetMapping
with a status
parameter that should not be visible in the query url, maybe it's also worth taking a look at @RequestHeaders
?
For example: @RequestHeader("status") Boolean status
Answered By - Ahmed Sayed
Answer Checked By - Marie Seifert (JavaFixing Admin)