We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@RequestParam
form
query
I'm using.
v3.4.0
v2.7.0
The @RequestParam annotation is tricky. Spring Boot will scan query and form to pass data to annotated variable.
@PostMapping(path = "/process", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseStatus(value = HttpStatus.OK) public String process( @Boolean @RequestParam(name = "is_dummy", defaultValue = "false") String isDummy, @Min(10) @RequestParam(name = "age") int age ) { return ""; }
For this definition, doing a cURL or request from generated API Docs will not work.
cURL
curl -X 'POST' \ 'http://localhost:8080/process?is_dummy=false&age=11' \ -H 'accept: application/json' \ -d ''
Few issues here.
org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type is not supported
Form Url Encoded
Instead, cURL should like below.
curl -X 'POST' \ 'http://localhost:8080/process' \ -H 'accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'age=11&is_dummy=false'
It's possible to fix given code by removing consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE. So we got.
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE
Then cURL works. Although I still we'd love to have a possibility to tell users to send a data in form instead of query.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm using.
v3.4.0
v2.7.0
The
@RequestParam
annotation is tricky. Spring Boot will scanquery
andform
to pass data to annotated variable.For this definition, doing a cURL or request from generated API Docs will not work.
cURL
Few issues here.
org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type is not supported
exception.form
instead ofquery
.Form Url Encoded
, but still Swagger do not setup a content-type.Instead, cURL should like below.
It's possible to fix given code by removing
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE
. So we got.Then cURL works. Although I still we'd love to have a possibility to tell users to send a data in
form
instead ofquery
.The text was updated successfully, but these errors were encountered: