https://kotlinlang.org logo
#kotless
Title
# kotless
s

Sebastian Kazenbroot-Guppy

09/08/2020, 10:25 PM
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

dector

09/10/2020, 9:43 AM
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

TanVD

09/10/2020, 1:23 PM
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

Sebastian Kazenbroot-Guppy

09/15/2020, 8:37 PM
@TanVD sorry, late response: running locally with Ktor, I can access the same JSON endpoint directly in the browser without issue
7 Views