gpt4 book ai didi

ios - 如何在 Alamofire 中发送数据

转载 作者:行者123 更新时间:2023-11-29 00:30:21 24 4
gpt4 key购买 nike

let headers: HTTPHeaders = [
"Accept": "application/json",
"Authorization" : "Token d3f237ec2fab24f874678029b15edfa746003111"
]

let parameters: [String:Any] = [
"firstname":fristName ,
"lastname" :lastName ,
"homeemail" : mail ,
"prorole" : [

"pro" : GymID,
"user" :"",
"role" : 9
],

"phone_details_user" : [

"phoneType" : 1 ,
"phoneNumer" : mobile
],
]

我发送数据为

Alamofire.request(URL, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
.responseJSON { response in

switch response.result {
case .success(let JSON):

successCallback((), JSON as Any as AnyObject)

case .failure(let error):
print(error)
}
}

它给出错误responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 “字符 0 周围的值无效。”UserInfo={NSDebugDescription=字符 0 周围的值无效。}))

最佳答案

来自服务器的响应不是有效的 json,请尝试使用 responseStringresponseDataresponse 找出问题所在。

关于ios - 如何在 Alamofire 中发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42024868/

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