<https://api.ktor.io/1.3.2/io.ktor.client.statemen...
# ktor
h
https://api.ktor.io/1.3.2/io.ktor.client.statement/read-text.html How come this responds with an error if the response code is not 200?
Copy code
HttpClient().use { client ->
 val response = client.submitForm<HttpResponse>(
  url = "<https://discord.com/api/oauth2/token>",
  formParameters = Parameters.build {
   append("client_id", config.discord.client)
   append("client_secret", config.discord.secret)
   append("grant_type", "authorization_code")
   append("redirect_uri", config.discord.redirect)
   append("scope", "identify")
   append("code", code)
  })
  println(response.readText()) // throws an error if response status is not 200.
}
a
set expectSuccess to false
h
👍
a
Copy code
val client = HttpClient{
        expectSuccess = false
    }
h
yep 😄