How to receive a form parameters using receive<T>?
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 14.5k
- Forks
- 1.3k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 49
Description
Base on the document, ktor supports receiving a form parameters (urlencoded or multipart) using receive<T>. Form Parameters (urlencoded or multipart)
However, the following source return HTTP status 415
<form method="post" action="/create">
<input type="text" name="foo">
<input type="text" name="bar">
<input type="submit">
</form>
data class Request(val foo: String, val bar: String)
val request = call.receive<Request>()
I know, there is call.receiveParameters() but, IMHO, it is not practical. I am not sure the manual is not correct or my code is wrong. How can I make the above code works?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Form Parameters documentation and reproduce the 415 response using the HTML form and call.receive() shown here. Compare that behavior with call.receiveParameters() and determine whether the documentation or the expected usage is incorrect. Done means the supported approach for receiving these form fields is clearly documented or the reported behavior is fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100