gpt4 book ai didi

swift - RxAlamofire 使用 json 主体进行 post 调用

转载 作者:行者123 更新时间:2023-11-28 13:39:36 28 4
gpt4 key购买 nike

我想使用 RxAlamofire 进行 post 调用,但找不到任何方法可以做到这一点

尝试使用 requestJSON 方法但没有参数传递 post json

 RxAlamofire.requestJSON(.post, url)

如何在 RxAlamofire 中进行 post 调用并将 json 数据传递给 post 调用

最佳答案

使用下面的代码

  var request = URLRequest(url: URL(string: "https://some_url")!)
//Following code to pass post json
request.httpBody = json
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
RxAlamofire.request(request as URLRequestConvertible).responseJSON().asObservable()

关于swift - RxAlamofire 使用 json 主体进行 post 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56232506/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com