https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ktor
  • k

    keochris

    03/08/2020, 5:23 PM
    Hello All! I’ve got an issue running a JS script for a route in #ktor . Indeed, whatever syntax I use or whater location I put the static files, I cannot manage to get anything else than a 404 not found error when refreshing the page. Is there anything obvious that I do wrong? Thanks very much for your help !
    s
    c
    r
    • 4
    • 11
  • e

    Evan R.

    03/09/2020, 4:20 AM
    Hey all! How is everyone else generating API docs for their ktor servers? Are you writing by hand? Is this a good choice?: https://github.com/nielsfalk/ktor-swagger Is there another tool you prefer?
    h
    s
    • 3
    • 3
  • h

    Henrik

    03/09/2020, 10:23 AM
    Are there any news on when ktor 1.3.2 will be released?
    👀 3
    s
    t
    • 3
    • 9
  • g

    gotoOla

    03/09/2020, 2:46 PM
    Hi! Has anyone here done any implementation of OpenTracing using ktor? Most Java Implementations are using MDC/thread locals but with coroutines I would suspect you need another approach?
    f
    • 2
    • 1
  • b

    bitkid

    03/09/2020, 3:06 PM
    Hi! I have a question regarding oauth2. I have one endpoint which uses ktors oauth feature and i got it working with the microsoft open ID thing. i get back an auth token and a refresh token. How should i protect all my other endpoints when i already have valid tokens? just with the JWT auth feature where i always pass the obtained auth token? it seems like i can't pass the token (as Bearer) to the auth endpoint, it always tries to redirect me to the auth provider.
    • 1
    • 1
  • t

    tim

    03/10/2020, 10:14 AM
    Hi I'm trying to ensure that every request has a cookie before the request gets to my routes (and initialise a new one if one doesn't exist already). I'm coming from NodeJS/Express so I'm looking the the middleware equivalent. Do I need to write a custom feature for this or is there an easier way to intercept the request and add the cookie if its not there already? In addition to this I'd like to have a authOnly high order function to deny access to certain routes ... i suppose i could do something like
    get("/path") = authOnly { ... }
    ? but figured there's a common approach to solving these?
    • 1
    • 2
  • v

    Vadim Briliantov

    03/10/2020, 6:53 PM
    ❓❓❓❓ Hi, I am now researching the situation with Swagger support in Ktor. If anyone is using Swagger please tell me which problems are you facing? I also found this project: https://github.com/nielsfalk/ktor-swagger?files=1 and some other community-driven implementation. If anyone tried them please tell your experience. Any response would be appreciated ❓❓❓
    e
    m
    • 3
    • 5
  • h

    hmole

    03/11/2020, 1:47 PM
    Can someone explain why this simple
    Location
    stops workingif I add an optional "packaging" parameter which is supposed to come from query? Uncommenting packaging property makes this location 404, works otherwise. Is there another hidded knowledge when attempting to work with locations besides incorrect imports? Ktor version is 1.1.2
    @Location(path = "{artifact}/{version}")
      data class Request(
        val artifact: String,
        val version: String/*,
        val packaging: String*/
      )
    
      fun Application.init() {
        routing {
          route("myRoute") {
            get <Request> { request -> call.respond("") }
            head<Request> { request -> call.respond("") }
          }
        }
      }
    e
    • 2
    • 2
  • s

    spierce7

    03/11/2020, 7:09 PM
    Are we going to see a release for ktor against Kotlin 1.3.70? All the prereqs seem to be there now.
    n
    • 2
    • 1
  • j

    Jamy

    03/12/2020, 4:59 AM
    Hi, I need to authorize ios and android application to request my API but globally I don’t know what I need to do. Is one JWT enough? I would likes to make same system as facebook or Spotify. A simple token in my app but I need a secure solution and I don’t know if JWT is enough. Do you have any ideas or advice for me? I must confess that Google answers me that OAuth has nothing to do with what I’m looking for.
    s
    • 2
    • 2
  • c

    cy

    03/12/2020, 11:21 AM
    📣 ktor
    1.3.2
    (with Kotlin 1.3.70 and serialization 0.20.0 has been released • Introduced iOS streaming response support • Provided challenge handler in iOS client configuration • Improved JsonFeature configuration DSL (#1472) • Simplified server kotlinx.serialization config • Recovered
    HttpRequestBuilder.takeFrom
    function (#1626) • Allowed to configure default cookies asynchronously • Exposed server
    LocationInfo
    and added location resolve functions (#1657) • Introduced function for async writing to server response channel (#1703) • Added an option to filter logged calls for ktor-client-logging • Fixed iOS client timeouts • Fixed iOS crash • Fixed 100% CPU Apache Ktor Http Client #1018 (#1689) • Fixed missing client response logging • Fixed CIO server local address detection (#1663) • Fix server request origin to provide header's host and port when available • Fixed random missing feature errors caused by concurrency at startup (#1694) • Fixed
    Set-Cookie
    header parser in iOS and JS • Fixed client multiple redirects with relative path (#1704) • Fixed unwrapping cancellation exceptions in client (#1482) • Fixed missed preconfigured
    OkHttpClient
    in
    OkHttpEngine
    (#1646) • Fixed websocket to complete closeReason on disconnection (#1275). • Fixed websocket sending CloseReason(1009) when frame is too big • Fixed websocket pinger logging • Fixed maxFrameSize for chunked frames • Fixed URL scheme parser (#1614) • Fixed platform detection in
    PlatformUtils.IS_NODE
    and
    PlatformUtils.IS_BROWSER
    (#1675) • Fixed
    Short.highByte
    • Fixed consumeEachBufferRange (#1693) • Fixed httpclient gzip decoding failure (#1189) • Fixed
    InputStream
    wrapper for
    Input
    • Bumped versions: • Kotlin 1.3.70 • kotlinx.coroutines 1.3.4 • kotlinx.serialization 0.20.0 • kotlinx.html 0.7.1 • dropwizard 4.1.2 • slf4j 1.7.30 • mustache 0.9.6 • pebble 3.1.2 • webjars 0.43 • jackson 2.10.2 Known issues: • Reverted fix for ios memory leak to prevent crashes ❗ No maven central publication due to an unknown verification error
    👍 1
    🔥 1
    🎉 37
    n
    • 2
    • 1
  • g

    gotoOla

    03/12/2020, 1:43 PM
    does anyone know about a kafka client written in kotlin that could be used with ktor or should one just roll with the java-client?
    e
    • 2
    • 2
  • g

    gabin

    03/12/2020, 2:33 PM
    Hi guys, I’m getting this exception from time to time . can you point what does it mean - “Bad position (limit 50): 51” ? I’m sure that response is not empty ktor 1.3.2 , ktor-client-android
    03-12 16:17:18.737 4006-4006/com.testapp.android D/NFApi: In validate response method. status: 404 Not Found
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err: java.lang.IllegalArgumentException: Bad position (limit 50): 51
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at java.nio.Buffer.positionImpl(Buffer.java:357)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at java.nio.Buffer.position(Buffer.java:351)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.charsets.UTFKt.decodeUTF8Line_array(UTF.kt:661)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.charsets.UTFKt.decodeUTF8Line(UTF.kt:36)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel$readUTF8LineToUtf8Suspend$2.invokeSuspend(ByteBufferChannel.kt:2120)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel$readUTF8LineToUtf8Suspend$2.invoke(ByteBufferChannel.kt)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.lookAheadSuspend$suspendImpl(ByteBufferChannel.kt:1877)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.lookAheadSuspend(ByteBufferChannel.kt)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.readUTF8LineToUtf8Suspend(ByteBufferChannel.kt:2116)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.readUTF8LineToAscii(ByteBufferChannel.kt:2056)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.readUTF8LineTo$suspendImpl(ByteBufferChannel.kt:2144)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.readUTF8LineTo(ByteBufferChannel.kt)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.readUTF8Line$suspendImpl(ByteBufferChannel.kt:2148)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteBufferChannel.readUTF8Line(ByteBufferChannel.kt)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at <http://io.ktor.utils.io|io.ktor.utils.io>.ByteReadChannelKt.readUTF8Line(ByteReadChannel.kt:223)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at com.testapp.lib.network.NFApi$client$2$1$4$1.invokeSuspend(NFApi.kt:57)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at com.testapp.lib.network.NFApi$client$2$1$4$1.invoke(NFApi.kt)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.client.features.HttpCallValidator.validateResponse(HttpCallValidator.kt:37)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.client.features.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:99)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.client.features.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:318)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:163)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:183)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:27)
    03-12 16:17:18.757 4006-4006/com.testapp.android W/System.err:     at io.ktor.client.call.HttpClientCall.receive(HttpClientCall.kt:75)
    e
    • 2
    • 2
  • r

    Rui

    03/12/2020, 2:52 PM
    Hi guys, what is the best way to store global objects and data through out the application? I'm thinking about creating a singleton class object in main function or Application.module(), but not sure if it's a good practice. Is there any solid example on that?
    e
    • 2
    • 2
  • r

    rahulrav

    03/12/2020, 3:43 PM
    Is there a way to request
    ktor
    dispatch requests using a
    CoroutineContext
    ?
    e
    • 2
    • 1
  • c

    Czar

    03/13/2020, 2:08 AM
    when this is executed, response contains redirect 302 and the code throws UnhandledRedirectionException. if I do the same request with httpie, I get status 200 and correct response. Am I doing something wrong with ktor client?
    ktor.client.kts
    e
    • 2
    • 7
  • g

    gabin

    03/13/2020, 9:55 AM
    Hello guys, is there any access to logging feature from the outside? I’d like to log some custom events using existing possibilities. (ktor-client-android, org.slf4j:slf4j-android)
    e
    • 2
    • 1
  • m

    Marc Knaup

    03/13/2020, 10:47 AM
    It would be nice if Ktor could provide a
    DslMarker
    so that we can mix `Application`/`ApplicationCall`/`Route`/`PipelineInterceptor` etc. receivers with our own server setup DSL 🙂
    c
    • 2
    • 5
  • m

    Marc Knaup

    03/13/2020, 10:50 AM
    It would be even more awesome if all those classes would be interfaces, so that you can create a new interface that implements them by delegation. That would allow bringing many extensions in scope!
    c
    • 2
    • 10
  • g

    gabin

    03/13/2020, 11:37 AM
    the logging feature doesn’t log request body, only response body . Is it intended?
    e
    • 2
    • 2
  • d

    dambakk

    03/13/2020, 5:32 PM
    Hi! I try to make a request with a body of id’s. So I have a serializable data class IdWrapper(val id: String) and set the body of the request to a list of IdWrapper instances. I though that should be it, but I get an exception saying “IdWrapper cannot be cast to String” when setting the `HttpRequestBuilder`’s body. Why is it expecting a String? Shouldn’t it accept
    Any
    serializable object?
    c
    • 2
    • 5
  • m

    Marc Knaup

    03/14/2020, 10:57 AM
    How do I add attributes for the lifecycle of a call within a route? E.g. 1. route enter -> call.attributes.put(…) 2. all route logic 3. route exit -> call.attributes.remove(…) Currently I’m trying the following, but it exits before the route is “run”:
    intercept(ApplicationCallPipeline.Setup) {
       // add attribute
       proceed()
       // remove attribute
    }
    • 1
    • 1
  • c

    Czar

    03/14/2020, 2:58 PM
    is there a way to make ktor log request bodies?
    e
    • 2
    • 8
  • w

    waltermcq

    03/15/2020, 1:14 AM
    @Nir Golan I'm doing the same course 😉 originally I found that calling the API with that request broke it; I never figured out exactly why but I believe the error is because moshi is looking for a
    {
    character but is getting a
    "
    as a result of the call body
    n
    • 2
    • 1
  • g

    Gunslingor

    03/15/2020, 2:57 AM
    how do I appropriately send these files as part of the page when this page is taken?
    • 1
    • 1
  • f

    foxx1337

    03/15/2020, 3:03 PM
    Is it possible to configure ktor to automatically insert a trailing slash for requests on
    static
    directories? I got
    static("ui") {
                resources("swagger-ui")
                resource("api.json")
                defaultResource("swagger-ui/index.html")
            }
    and when I browse the server at
    server/path/to/ui
    I actually see that
    index.html
    file (direct 200, no reidrects) but I see none of the static resources the
    index.html
    tries to load (it addresses them like
    ./resource
    ). Those static resources load just fine if I navigate to
    server/path/to/ui/
    (notice the trailing slash).
    g
    j
    • 3
    • 7
  • g

    Gunslingor

    03/15/2020, 5:23 PM
    Doesn't seem like many people are active on here, questioning whether I should be using ktor instead of spring boot on this project now 😃 lol. Why doesn't the Ktor IntelliJ plug in give an option for KotlinJS... I have three.js being served up but now I need figure out the best way to use it in ktor... simple thing took me all night, I miss the old days! lol... well I suspect it will pay off in the long run. I think I undertand I need a HttpClient(Js) but I can't seem to get that library to load using the gradle line on the site.
    • 1
    • 3
  • g

    Gunslingor

    03/15/2020, 6:48 PM
    Now I'm confused, it looks like it isn't implemented yet? https://github.com/ktorio/ktor/blob/master/ktor-client/ktor-client-js/js/src/Js.kt
    e
    • 2
    • 5
  • r

    Rodrigo Silva

    03/15/2020, 8:04 PM
    I want to create a SPA using kotlinjs, what is the best way? With gradle -> koltinjs or ktor -> client side -> kotlinjs?
    r
    • 2
    • 1
  • n

    napperley

    03/16/2020, 3:50 AM
    Is it possible to exclude a HTTP response from being serialised? The code below triggers a InvalidMutabilityException:
    @UnstableDefault
    private suspend fun runGenericPromQlQuery(host: String, port: Int, query: String): String =
        <http://httpClient.post|httpClient.post>("http://$host:$port") {
            contentType(ContentType.parse(FORM_URL_ENCODED))
            body = listOf("query" to query).formUrlEncode()
        }
    e
    • 2
    • 3
Powered by Linen
Title
n

napperley

03/16/2020, 3:50 AM
Is it possible to exclude a HTTP response from being serialised? The code below triggers a InvalidMutabilityException:
@UnstableDefault
private suspend fun runGenericPromQlQuery(host: String, port: Int, query: String): String =
    <http://httpClient.post|httpClient.post>("http://$host:$port") {
        contentType(ContentType.parse(FORM_URL_ENCODED))
        body = listOf("query" to query).formUrlEncode()
    }
Below is the stack trace:
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.collections.HashMap@c15f78
        at kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable (0x2f7117)
        at kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception (0x2f0a25)
        at kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException (0x2f05e5)
        at kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException (0x31e765)
        at ThrowInvalidMutabilityException (0x31fe53)
        at MutationCheck (0x63f80e)
        at kfun:kotlin.collections.HashMap.<set-length>#internal (0x301ccd)
        at kfun:kotlin.collections.HashMap.addKey$stdlib(K)<http://kotlin.Int|kotlin.Int> (0x3062fb)
        at kfun:kotlin.collections.HashMap.put(K;V)V? (0x302cd9)
        at kfun:io.ktor.util.AttributesNative.put#internal (0x4dfc5f)
        at kfun:io.ktor.client.features.$addDefaultResponseValidation$lambda-1$lambda-0COROUTINE$18.invokeSuspend#internal (0x53a41c)
        at kfun:io.ktor.client.features.$addDefaultResponseValidation$lambda-1$lambda-0COROUTINE$18.invoke#internal (0x53aad2)
        at kfun:io.ktor.client.features.HttpCallValidator.$validateResponseCOROUTINE$24.invokeSuspend#internal (0x54326c)
        at kfun:io.ktor.client.features.HttpCallValidator.validateResponse#internal (0x543586)
        at kfun:io.ktor.client.features.HttpCallValidator.Companion.$install$lambda-1COROUTINE$23.invokeSuspend#internal (0x5461b0)
        at kfun:io.ktor.client.features.HttpCallValidator.Companion.$install$lambda-1COROUTINE$23.invoke#internal (0x546b0f)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.loop#internal (0x4dc1dd)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.proceed#internal (0x4db85e)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.execute#internal (0x4dbc61)
        at kfun:io.ktor.util.pipeline.Pipeline.execute(TContext;TSubject)TSubject (0x4d6a30)
        at kfun:io.ktor.client.call.HttpClientCall.$receiveCOROUTINE$13.invokeSuspend(kotlin.Result<kotlin.Any?>)kotlin.Any? (0x52d097)
        at kfun:io.ktor.client.call.HttpClientCall.receive(io.ktor.client.call.TypeInfo)kotlin.Any (0x52d706)
        at kfun:com.chapman.batteryMetricsExtractor.$runGenericPromQlQueryCOROUTINE$0.invokeSuspend#internal (0x5f2dc5)
        at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) (0x3125a8)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal (0x4dc8a8)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.loop#internal (0x4dc413)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal (0x4de42c)
        at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) (0x312889)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal (0x4dc8a8)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.loop#internal (0x4dc413)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal (0x4de42c)
        at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) (0x312889)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal (0x4dc8a8)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.loop#internal (0x4dc413)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal (0x4de42c)
        at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) (0x312889)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal (0x4dc8a8)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.loop#internal (0x4dc413)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal (0x4de42c)
        at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) (0x312889)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal (0x4dc8a8)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.loop#internal (0x4dc413)
        at kfun:io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal (0x4de42c)
        at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) (0x312889)
        at kfun:kotlinx.coroutines.DispatchedTask.run() (0x3f9aca)
        at kfun:kotlinx.coroutines.EventLoopImplBase.processNextEvent()kotlin.Long (0x3d5480)
        at kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal (0x406afe)
        at kfun:kotlinx.coroutines.runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,T>){0<kotlin.Any?>}Generic (0x405be8)
        at kfun:kotlinx.coroutines.runBlocking$default(kotlin.coroutines.CoroutineContext?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,T>;<http://kotlin.Int|kotlin.Int>){0<kotlin.Any?>}Generic (0x406121)
        at kfun:com.chapman.batteryMetricsExtractor.main(kotlin.Array<kotlin.String>) (0x5f0848)
        at Konan_start (0x5f771b)
        at Init_and_run_start (0x61c08b)
        at __libc_start_main (0x7f291a21bb97)
        at  (0x2ac029)
        at  ((nil))
e

e5l

03/16/2020, 2:47 PM
Hi @napperley, what do you mean by
being serialized
here? We should encode list somehow
n

napperley

03/16/2020, 8:35 PM
I want to make it that the body from the HTTP response isn't being handled by the KotlinX Serialization library, and is just a String being returned (not converted to a custom data type).
View count: 4