gpt4 book ai didi

ios - 如何在 Alamofire 中将原始数据作为参数发布?

转载 作者:搜寻专家 更新时间:2023-11-01 06:27:12 25 4
gpt4 key购买 nike

如何在 Alamofire 中发布这种形式的参数?

[{"view_id":"108","Class_id":"VIII"}]

通常 Alamofire 接受 [String:Any] 参数,当我在 Alamofire 请求中输入此参数时,它会引发错误:

"extra call method"

最佳答案

你说 Alamofire 通常接受 [String:Any] 参数 然后你传递 [[String: Any]]

尝试在 hhtpBody 中传递您的数据。

let urlString            = "yourString"
guard let url = URL(string: urlString) else {return}
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
do {
request.httpBody = try JSONSerialization.data(withJSONObject: your_parameter_aaray)
} catch let error {
print("Error : \(error.localizedDescription)")
}
Alamofire.request(request).responseJSON{ (response) in
}

关于ios - 如何在 Alamofire 中将原始数据作为参数发布?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52776088/

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