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

发布于 2025-01-10 08:04:58 字数 412 浏览 3 评论 0原文

卷曲 -X POST
-H“X-解析应用程序-Id:ehUKQVObBspFk0MBFNSSg3MwLJofpeoFtDhQNIgS”
-H“X-解析-REST-API-密钥:9HNNfwY6ITbUGqsfMSJS3OlQVqYfm5EAiZWVe012”
-H“内容类型:application/json”
-d "{ "file_type":"一个字符串","encryption_tool_id":"一个字符串","user_id":"一个字符串","query":"一个字符串" }"
https://encyriptionapp.b4a.io/classes/UserFiles

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花间憩 2025-01-17 08:04:58
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。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文