【发布时间】:2018-04-26 08:07:32
【问题描述】:
您好,我想向 API 发出请求,但是发送时,控制台会显示给我
无效的网址
Alamofire.request("https://.../api/v1.8/set/order/?address=\(address)&email=\(email)&information=\(information)&name=\(name)&order=\(parameters)&password=\(password)&paymentType=\(paymentType)&phone=\(phone)&token=\(token)&userID=\(userID)&wihtRegistration=\(wihtRegistration)").validate(statusCode: 200..<300)
.responseJSON { response in
switch response.result
{
case .failure(let error):
print(error)
case .success(let value):
print(value)
print("Request: \(response.request)")
}
}
如何在 Alamofire 中转换?
【问题讨论】:
-
“转换”是什么意思?我认为“invalidURL”错误很清楚,你应该检查“https://.../api/v1.8/set/order/?address=(address)&email=(email)&information=(information) &name=(name)&order=(parameters)&password=(password)&paymentType=(paymentType)&phone=(phone)&token=(token)&userID=(userID)&wihtRegistration=(wihtRegistration)"
-
"address=(address)":如果有空格,可能会失败。另外,为什么不使用那里的参数来为你做呢?
-
没有空格,为了我需要请求 [{:}] 订购
-
如果你这样做
let url = URL(string:yourString)是url不是nil? -
不,我通过
Alamofire.request("https://..")