https://kotlinlang.org logo
#ktor
Title
# ktor
p

pavlospt

03/24/2020, 10:53 AM
Hey friends! 🙂 I have a question regarding
HttpClient
usage. If I want to execute an API call when someone “hits” a specific endpoint, do I just need to call
<http://client.post|client.post>(…)
inside the route callback, or am I missing something? It is like the call is never executed and cancelled after the specified timeout..! Thanks in advance!
e

e5l

03/24/2020, 10:55 AM
Hi @pavlospt,
<http://client.post|client.post>(...)
should be enough. To clarify where it stucks you can enable
Logging
feature
p

pavlospt

03/24/2020, 10:56 AM
Hey @e5l, how do I do that for HttpClients? I am not sure if I missed it in the documentation 😕
p

pavlospt

03/24/2020, 10:57 AM
Yes totally missed it. Thank you!
👍 1
Do I need to create a new HttpClient for each API call I want to execute?
Seems like the call is starting but never finishes
e

e5l

03/24/2020, 11:19 AM
nope
p

pavlospt

03/24/2020, 11:20 AM
Then the usage of
.use
is still valid if I want to use the same client?
e

e5l

03/24/2020, 11:20 AM
Could you provide the example?
p

pavlospt

03/24/2020, 11:21 AM
Give me a minute to move that to a Gist!
Also from what I see in the logs, the API request seems to be initiating, but never completing!
🤔 1
e

e5l

03/24/2020, 12:10 PM
Sorry, I can’t reproduce it. Could you replace the client endpoint with your own server?
p

pavlospt

03/24/2020, 12:14 PM
the client endpoint is responding properly, because I also have another CLI app that is using the same client endpoint
Apparently it has something to do with the platform that I am hosting the application. It seems that it can complete without timing out in like 1/5 tries! Thank you for your help & time 😄
😉 1