Hunter Kelly

03/03/2021, 2:07 PM
Hi there, I’m trying to pass a json object into a post request, my function looks like this:
Copy code
fun createItems(info: ItemInfo): HttpResponse {
    return HttpResponse(201, MimeType.JSON, "")

data class ItemInfo(
    val name: String,
    val count: Int,
    val details: String,
But when I make the following call, I get an error that the parameter is missing:
Copy code
POST /1/createItems HTTP/1.1
Accept: application/json, */*;q=0.5

    "info": {
        "count": 10,
        "details": "test1 details",
        "name": "test1"
Response is:
Copy code
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Content-Length: 35
Content-Type: text/plain
Date: Wed, 03 Mar 2021 13:56:42 GMT

Required argument 'info' is missing
Are json objects not supported? I can rewrite to flatten object, but it seems like one of the main value propositions of kotless is being able to work with kotlin and objects in a clean way and without all the normal headache of marshalling/unmarshalling things


03/04/2021, 8:15 AM
Hm, we had this discussion above — basically automatic demarshalling from post body was disabled, but probably we should return it
Still you can use Ktor which has this support

Christian Schwoerer

03/04/2021, 4:22 PM
Hi @Hunter Kelly, see my question / solution here:
But in the end we decided to switch to Ktor