繁体   English   中英

我如何使用 Ktor Client For Kotlin-multiplatform 执行这个 cURL?

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

curl -X POST
-H "X-Parse-Application-Id: ehUKQVObBspFk0MBFNSSg3MwLJofpeoFtDhQNIgS"
-H“X-解析-REST-API-密钥:9HNNfwY6ITbUGqsfMSJS3OlQVqYfm5EAiZWVe012”
-H“内容类型:应用程序/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()
}

此外,您可以使用JsonFeature将对象序列化为 JSON。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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