Skip to content

Instantly share code, notes, and snippets.

@ToxicMushroom
Last active May 25, 2022 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToxicMushroom/975601e26be80994a57487e043a3e6dc to your computer and use it in GitHub Desktop.
Save ToxicMushroom/975601e26be80994a57487e043a3e6dc to your computer and use it in GitHub Desktop.
val commonClientConfig: HttpClientConfig<OkHttpConfig>.() -> Unit = {
expectSuccess = false
install(ContentNegotiation) {
jackson {
disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES)
disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
}
}
install(UserAgent) {
agent = "Melijn / 3.0.0 Discord bot"
}
}
val httpClient = HttpClient(OkHttp, commonClientConfig)
webManager.httpClient.post("https://graphql.anilist.co") {
val body1 =
"{ \"operationName\":\"SearchMedia\", \"variables\":{ \"name\":\"erased\", \"type\":\"MANGA\" }, \"query\":\"query SearchMedia(\$name: String!, \$type: MediaType!) { Page(page: 1, perPage: 10) { __typename media(search: \$name, type: \$type) { __typename id title { __typename romaji english native userPreferred } siteUrl favourites } } }\" }"
println(body1)
setBody(TextContent(body1, ContentType.Application.Json))
contentType(ContentType.Application.Json)
}.body<String>()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment