curl post application/x-www-form-urlencoded throw MissingServletRequestParameterException
See original GitHub issueI use spring-boot 2.2.x
My code is:
@PostMapping(path = "/testFormData", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public BaseResult testFormData(@RequestParam(name = "name") String name,
@RequestParam(name = "age") Integer age) {
log.info("api testFormData name is {}, age is {}", name, age);
return BaseResult.success(name + "---" + age);
}
and I use curl:
curl -XPOST "http://127.0.0.1:8082/api/testFormData" -d "name=jackson&age=24"
and it throws a MissingServletRequestParameterException
.
If I use spring-boot 2.1.x, the request is OK.
How can I resolve application/x-www-form-urlencoded
post request?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Content type 'application/x-www-form-urlencoded;charset ...
The problem is that when we use application/x-www-form-urlencoded, Spring doesn't understand it as a RequestBody. So, if we want to use this we...
Read more >How do I post form data using Curl? - ReqBin
In this Curl POST Form example, we submit a form to a ReqBin echo URL in the application/x-www-form-urlencoded format. Click Run to execute ......
Read more >How do I make a POST request using curl? - Super User
This will be POST-ed as application/x-www-form-urlencoded (used for the majority of forms that don't contain file uploads): curl http://httpbin.org/post ...
Read more >How to send POST Request with JSON Payload using Curl ...
In this article, you will learn how to post JSON data with curl command to test your Spring REST application. If you know...
Read more >Perform a POST Request Using Curl [Practical Examples]
application /x-www-form-urlencoded which is used when submitting a web form to the server and multipart/form-data which is used to upload files to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i found i add an accessLogFilter, and create a
HttpServletRequestAdapter
if i add
param has this problem
if i am not use
every thing is ok
but i use spring-boot 2.1.x also add this accessLogFilter, request param is ok.
We were having the same problem and we later realised it was because of a filter in the chain that was consuming the request
InputStream
.If you are doing the same,
ContentCachingRequestWrapper
andContentCachingResponseWrapper
may be useful as well as relying onAbstractRequestLoggingFilter
if you’re doing that for logging purposes.