something strange seems to be happening with my ap...
# ktor
w
something strange seems to be happening with my app:
Copy code
post("/webhook", {
            print("yes")
            val post = call.receiveParameters()
            print("yes")
o
It could be if sender of
POST
request is not sending any data and not sending an indication of empty request (Content-Length: 0 or zero-chunk), and not closing connection. In this case the handler is suspended and waiting for data. How do you send the data to
webhook
?
w
using curl
Copy code
curl -H "Content-Type: application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}'
basically I am just following the Facebook dev guide for making a chat bot
o
I will need to check it locally. Will be able to do it later today.
👍 1
w
Okay thanks a lot. 🙂
o
Wait, you’re likely having an exception in log.
receiveParameters
will not work with JSON, it is for form posts (multipart or urlencoded). If you need to receive a data object, you need to setup
ContentNegotiation
and recieve a data object.
w
No exceptions showing up in run tab on intellij...but this is probably the reason.
o
Did you setup logging?
I mean, did you read the gradle guide to the end? 😄
w
Ah no I didn't 😛. I did read it but figured I could do without logging to begin with
will set it up now (y)
also any link to the documentation on receiving data object?
i.e. content negotiation for json
o
Not yet… but check samples!
@Deactivated User 🙂
👍 1
w
Alright will do 🙂
d
Nice! Thanks for asking, that helps a lot to locate things that are missing 🙂 I’m still with the Requests/Responses stuff, but will enqueue this too 👍
👍 1
w
Happy to help any way I can. 🙂 I've been a huge Jetbrains fan for years.
simple smile 1
d
Added a Requests page (hope it is helpful): http://ktor.io/servers/requests.html And a section about the ContentNegotiation: http://ktor.io/servers/requests.html#receiving-content-negotitation Let me know if something is not clear or if you have troubles with other things so I can improve it.