【发布时间】:2018-04-29 03:32:09
【问题描述】:
我将通过 alamofire 发布请求。我可以使用 Postman 发布请求。响应返回 true(201 代码)。但是,当我尝试使用 Alamofire 时返回 404 代码。怎么了?
我的代码:
let headers: HTTPHeaders = [
"Authorization": "Basic xxxxxxxxxxxx",
"content-type": "application/json"
]
let parameters:[String:Any] = [
"xxx":123,
"yyy":"test",
"zzz":"iphone"
]
Alamofire.request(myUrl, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { response -> Void in
switch response.result {
case .success:
print(response.response?.statusCode)
break
case .failure(let error):
print(error)
}
}
返回此消息:
success {
message = "No HTTP resource was found that matches the request URI 'https://xxxxx/PostErrorFeedBack'.";
}
【问题讨论】:
-
这是
Content-Type,而不是content-type。 -
相同,没有任何改变
-
您要访问哪个 URL?它是公共 URL 还是您尝试访问自己的本地服务器?
-
似乎不是 404,根据消息它是一个成功的请求...这里的 404 到底在哪里?