rybalkinsd / kohttp

Kotlin DSL http client
https://kohttp.gitbook.io
Apache License 2.0
478 stars 42 forks source link

How can I use kohttp for this specific curl command? #209

Open elect86 opened 3 years ago

elect86 commented 3 years ago

I'd like to replace the usage of crude shell commands with a nice library, and kohttp looks quite promising

One example I'm testing against, it's from gradle kts exec{}:

commandLine("curl", "-X", "GET", "-H", "Authorization: token $token", "https://api.github.com/repos/kotlin-graphics/mary/contents/$path")

I tried to port that over to kohttp

    val response = httpGet {
        host = "https://api.github.com/repos/kotlin-graphics/mary/contents/$path"
        header {
            "-H" to "Authorization: token $token"
        }
    }

But unfortunately, all I get is:

What am I doing wrong?

Ps: sorry for asking this here if this is not the right place to