Unable to transform request
See original GitHub issueContent:
data class CreateAccountContent(
val id: Int,
val password: String
)
Main.kt:
fun main(args: Array<String>){
val handler = DatabaseHandler()
val server = embeddedServer(Netty, port = 12345) {
routing {
// ...
post("/account"){
try {
val post = call.receive<CreateAccountContent>()
if (handler.createUser(post)) {
call.respond(HttpStatusCode.OK, "OK")
} else {
call.respond(HttpStatusCode.BadRequest, "BAD")
}
} catch (e: Exception) {
println(e)
}
}
}
}
server.start(wait = true)
}
Curl request:
curl --request POST \
--header "Content-Type: application/json" \
--data '{"id": 7, "password": "ABCDEF"}' \
http://localhost:12345/account
Output:
io.ktor.request.CannotTransformToTypeException: Cannot transform this request's content to class com.martmists.moneyservice.content.CreateAccountContent
Alternatively, I have tried the following Lua code:
http.post("http://localhost:12345/account", -- url
"id=7&password=ABCDEF") -- POST Body
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Amazon APi gateway fails to generate transformed request
I was trying the integration of Amazon API gateway with Lambda function. I was successfully able to achieve though but when I tried...
Read more >Unable to transform request to binary · Issue #4628
To implement binary support in api-gateway for file upload, i have used serverless-apigw-binary plugin and added necessary content types ...
Read more >Lambda non-proxy integration errors out with "IntegrationError
Lambda non-proxy integration errors out with "IntegrationError: Execution failed due to configuration error: Unable to transform request".
Read more >Resolve "Execution failed due to configuration" errors from ...
Why am I getting “Execution failed due to configuration” errors from API Gateway after using a CloudFormation template or OpenAPI definition ...
Read more >Unable to get complete response when using api gateway
URL Path Parameters , URL Query String Parameters , HTTP Headers are empty . In Method Execution , Authorization , Request Validator are...
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
You have to install the ContentNegotiation feature: https://ktor.io/features/content-negotiation.html
For anyone else who hits this, my issue was that I mistakenly
install
edContentNegotiation
inside therouting
block and it should have been done outside it.