【问题标题】:alamofire extra argument in callalamofire 通话中的额外参数
【发布时间】:2017-07-01 06:16:05
【问题描述】:

过去 2 天面临这个问题。我已经更新了 pod,将 pod 版本从 4.0.1 更新为 4.5.0 但问题仍然相同。

这是我的代码:

var params: Parameters = [:]
        params = [
            "id": fetchFromCoreData(keyVlue: "trsptrRegistrationId") as AnyObject,
            "mobileNumber": fetchFromCoreData(keyVlue: "mobileNO") as AnyObject,
            "isNotification": isnotifyTag as AnyObject
        ]
        print(params)

        let auth_token = fetchFromCoreData(keyVlue: "Auth_Token")
        let headers = [
            "authKey": auth_token
        ]
        print(headers)


        let URL: String = GlobalUrls.BASE_URL + GlobalUrls.notifySetting
        print(URL)
        Alamofire.request(URL, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers)

【问题讨论】:

    标签: ios swift3 alamofire


    【解决方案1】:

    你能不能试试这个方法

    var param :Parameters
            param = [
                "id": "Any id",
                "mobileNumber": "any mobile number",
                "isNotification": "is notification"
            ]
    
            print(param)
    
            let auth_token = "your auth_token"
            let headers = [
                "authKey": auth_token
            ]
            print(headers)
    
    
            let base_url: String = "Here is my base URL"
            print(base_url)
            Alamofire.request(base_url, method: .post, parameters: param, encoding: JSONEncoding.default, headers: headers).responseJSON(completionHandler: {(resObj) -> Void in
    
                print(resObj)
    
                if resObj.result.isSuccess
                {
                    print("Sucess result")
                }
    
                if resObj.result.isFailure
                {
                    let error : Error = resObj.result.error!
                    print("Fail result")
                    print(error.localizedDescription)
    
                }
            })
    

    【讨论】:

    • 如果我从请求中删除标头,则错误得到解决
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-03
    • 2023-03-21
    • 2018-08-26
    • 2018-07-03
    • 2017-01-22
    相关资源
    最近更新 更多