“请求的资源不支持http方法'POST'。”;

时间:2019-04-19 18:25:42

标签: ios json swift post

我正在尝试在应用程序中使用Alamofire发出 POST 请求,但一直低于以下结果:

SUCCESS: {
    "$id" = 1;
    Message = "The requested resource does not support http method 'POST'.";
}

我已经在POSTMAN中测试了参数,在那里得到了正确的结果,但是在应用程序中遇到了问题。

enter image description here

网络类中的代码-:

 // 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"])
    }

0 个答案:

没有答案