Hi all! I deployed a Ktor Kotless app, exposing an...
# kotless
s
Hi all! I deployed a Ktor Kotless app, exposing an endpoint at
<https://api.sebastiankazenbrootguppy.com/topics|https://api.sebastiankazenbrootguppy.com/topics>
. This endpoint returns application/json. When visiting this endpoint in Chrome, I see
HTTP ERROR 406
(you likely do too). However, when I CURL the endpoint, or use the API Gateway test UI, it returns an array of five JSON entities like it's supposed to. Has anyone else encountered HTTP 406 issues with a Ktor Kotless app?
👀 2
d
That's because curl has default header
Accept: */*
. However, browsers use more complex headers (e.g. my Firefox sends
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
which includes
*/*
but in complex expression). My guess is that Kotless don't know to process complex
Accept
header yet. But if you will use
Accept: application/json
in your client - it'll work well.
👍 2
Try to use some apps like postman or hoppscotch:
Copy code
<https://hoppscotch.io/?method=GET&url=https://api.sebastiankazenbrootguppy.com&path=/topics&headers=[{>"key":"Accept","value":"application/json"}]
(with the latest you will need browser extension to overcome CORS issue - https://github.com/hoppscotch/hoppscotch-extension)
👍 1
t
Hm, @Sebastian Kazenbroot-Guppy does your application works locally the same way? It may be because of APIGateway (and in that case it is Kotless fault) or because of Ktor 🙂
s
@TanVD sorry, late response: running locally with Ktor, I can access the same JSON endpoint directly in the browser without issue