import UIKit
import Alamofire
import SwiftyJSON
class LoginViewController: UIViewController {
@IBOutlet weak var urlTextFiled: UITextField!
@IBOutlet weak var emailTextFiled: UITextField!
@IBOutlet weak var passwordTextFiled: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
guard let email = emailTextFiled.text, !email.isEmpty else {
return
}
guard let password = passwordTextFiled.text, !password.isEmpty else {
return
}
let db = "mohanad"
let url = "http://176.58.117.249/web/session/authenticate"
let parameters: [String: Any] = [
"db": db,
"login": email,
"password": password ,
]
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.default, headers: nil)
.validate(statusCode: 200..<600)
.responseJSON { response in
switch response.result
{
case .failure(let error):
print(error)
case .success(let value):
print(value)
}
}
}
}
输出以下错误信息:
注:此处为技术内容,如需更详细的解释或润色,请提供更多上下文信息。responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}))
Bad Request
。看一下我的答复。 - AshvinGudaliya