我正在尝试在应用程序中使用Alamofire
发出 POST 请求,但一直低于以下结果:
SUCCESS: {
"$id" = 1;
Message = "The requested resource does not support http method 'POST'.";
}
我已经在POSTMAN
中测试了参数,在那里得到了正确的结果,但是在应用程序中遇到了问题。
网络类中的代码-:
// Mark-: User Login
static func saveUserLoginDetails(url: String, parameters: [String: String]) {
print(parameters)
Alamofire.request(url,method: .post, parameters: parameters, encoding: URLEncoding.httpBody, headers: ["Content-Type": "application/x-www-form-urlencoded"]).responseJSON {
response in
switch response.result {
case .success:
print(response)
break
case .failure(let error):
print(error)
}
}
}
}
Login类中的方法,当API
单击时调用登录button
:
private func saveUserLoginResponse(){
AbcNetworking.saveUserLoginDetails(url:Constant.URL.school_Code , parameters: [
"grant_type":"password",
"username" : "surabhi@gmail.com",
"password":"lakhera8",
"Scope":"User"])
}