简体   繁体   中英

how can i excute this cURL with Ktor Client For Kotlin-multiplatform?

curl -X POST
-H "X-Parse-Application-Id: ehUKQVObBspFk0MBFNSSg3MwLJofpeoFtDhQNIgS"
-H "X-Parse-REST-API-Key: 9HNNfwY6ITbUGqsfMSJS3OlQVqYfm5EAiZWVe012"
-H "Content-Type: application/json"
-d "{ "file_type":"A string","encryption_tool_id":"A string","user_id":"A string","query":"A string" }"
https://encyriptionapp.b4a.io/classes/UserFiles

val client = HttpClient(Apache) {}

client.post<String>("https://encyriptionapp.b4a.io/classes/UserFiles") {
    headers.append("X-Parse-Application-Id", "ehUKQVObBspFk0MBFNSSg3MwLJofpeoFtDhQNIgS")
    headers.append("X-Parse-REST-API-Key", "9HNNfwY6ITbUGqsfMSJS3OlQVqYfm5EAiZWVe012")
    contentType(ContentType.Application.Json)
    body = """
        { "file_type":"A string","encryption_tool_id":"A string","user_id":"A string","query":"A string" }
    """.trimIndent()
}

Also, you can use the JsonFeature for serializing objects to JSON.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM