elvis
elvis

Reputation: 1168

Can I do a GET with request body in Spring Boot?

I'm using Spring Boot and Spring MVC and I need to make a GET with a request body. Is this possible?

I tried this but it's not working. I get 404.

@RestController
@RequestMapping("/api")
public class HomeController {

    @GetMapping("/v1/foo")
    public ApiRes postBody(@RequestBody ApiReq apiReq) {
        ...
    }
}

Upvotes: 1

Views: 12150

Answers (1)

D. Kowalski
D. Kowalski

Reputation: 51

Technically it is possible but it is against the HTTP API Design Guidelines. Request-Bodys should only be used for POST or PUT.

For further information: https://swagger.io/resources/articles/best-practices-in-api-design/

Upvotes: 4

Related Questions