{"action":"created","issue":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/773","labels_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/773/labels{/name}","comments_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/773/comments","events_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/773/events","html_url":"https://github.com/Alamofire/Alamofire/issues/773","id":106584675,"number":773,"title":"Put request failing with Alamofire 2.0","user":{"login":"mikewalkerjr","id":4707821,"avatar_url":"https://avatars.githubusercontent.com/u/4707821?v=3","gravatar_id":"","url":"https://api.github.com/users/mikewalkerjr","html_url":"https://github.com/mikewalkerjr","followers_url":"https://api.github.com/users/mikewalkerjr/followers","following_url":"https://api.github.com/users/mikewalkerjr/following{/other_user}","gists_url":"https://api.github.com/users/mikewalkerjr/gists{/gist_id}","starred_url":"https://api.github.com/users/mikewalkerjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikewalkerjr/subscriptions","organizations_url":"https://api.github.com/users/mikewalkerjr/orgs","repos_url":"https://api.github.com/users/mikewalkerjr/repos","events_url":"https://api.github.com/users/mikewalkerjr/events{/privacy}","received_events_url":"https://api.github.com/users/mikewalkerjr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Alamofire/Alamofire/labels/support","name":"support","color":"FC6808"}],"state":"closed","locked":false,"assignee":{"login":"cnoon","id":169110,"avatar_url":"https://avatars.githubusercontent.com/u/169110?v=3","gravatar_id":"","url":"https://api.github.com/users/cnoon","html_url":"https://github.com/cnoon","followers_url":"https://api.github.com/users/cnoon/followers","following_url":"https://api.github.com/users/cnoon/following{/other_user}","gists_url":"https://api.github.com/users/cnoon/gists{/gist_id}","starred_url":"https://api.github.com/users/cnoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnoon/subscriptions","organizations_url":"https://api.github.com/users/cnoon/orgs","repos_url":"https://api.github.com/users/cnoon/repos","events_url":"https://api.github.com/users/cnoon/events{/privacy}","received_events_url":"https://api.github.com/users/cnoon/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-09-15T15:42:50Z","updated_at":"2015-09-16T13:30:16Z","closed_at":"2015-09-16T06:26:04Z","body":"I have recently upgraded to Alamofire 2.0, and now my Put request is failing with a 400 error, when it was previously working properly. I perform the call with the code:\r\n\r\n        Alamofire.request(Router.Put(query: url, params: params, encoding: .JSON))\r\n            .validate()\r\n            .responseJSON() {\r\n                (request, response, result) in\r\n                \r\n                print(\"request: \\(request)\")\r\n                print(\"response: \\(response)\")\r\n                print(\"result: \\(result)\")\r\n                \r\n                switch result {\r\n                case .Success(_):\r\n                    // success\r\n                case .Failure(let data, _):\r\n                    // error occured\r\n                }\r\n        }\r\n\r\nand my custom Router class:\r\n\r\n    enum Router: URLRequestConvertible {\r\n    \r\n        case Get(query: String, params: [String: AnyObject]?)\r\n        case Post(query: String, params: [String: AnyObject]?)\r\n        case Put(query: String, params: [String: AnyObject]?, encoding: ParameterEncoding)\r\n        case Delete(query: String, params: [String: AnyObject]?)\r\n    \r\n        var URLRequest: NSMutableURLRequest {\r\n            var encodeMethod: Alamofire.ParameterEncoding = Alamofire.ParameterEncoding.URL\r\n        \r\n            // Default to GET\r\n            var httpMethod: String = Alamofire.Method.GET.rawValue\r\n        \r\n            let (path, parameters): (String, [String: AnyObject]?) = {\r\n                switch self {\r\n                case .Get(let query, let params):\r\n                    // Set the request call\r\n                    httpMethod = Alamofire.Method.GET.rawValue\r\n                    // Return the query\r\n                    return (query, params)\r\n                case .Post(let query, let params):\r\n                    // Set the request call\r\n                    httpMethod = Alamofire.Method.POST.rawValue\r\n                    // Return the query\r\n                    return (query, params)\r\n                case .Put(let query, let params, let encoding):\r\n                    // Set the request call\r\n                    httpMethod = Alamofire.Method.PUT.rawValue\r\n                    // Set the encoding\r\n                    encodeMethod = encoding\r\n                    // Return the query\r\n                    return (query, params)\r\n                case .Delete(let query, let params):\r\n                    // Set the request call\r\n                    httpMethod = Alamofire.Method.DELETE.rawValue\r\n                    // Return the query\r\n                    return (query, params)\r\n                }\r\n                }()\r\n        \r\n            // Create the URL Request\r\n            let URLRequest = NSMutableURLRequest(URL: NSURL(string: Globals.BASE_URL + path)!)\r\n            // set header fields\r\n            if let key = NSUserDefaults.standardUserDefaults().stringForKey(Globals.NS_KEY_SESSION) {\r\n                URLRequest.setValue(key, forHTTPHeaderField: \"X-BC-API\")\r\n            }\r\n            // Add user agent\r\n            if let userAgent = NSUserDefaults.standardUserDefaults().stringForKey(Globals.NS_KEY_USER_AGENT) {\r\n                URLRequest.setValue(userAgent, forHTTPHeaderField: \"User-Agent\")\r\n            }\r\n            \r\n            // Set the HTTP method\r\n            URLRequest.HTTPMethod = httpMethod\r\n        \r\n            URLRequest.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData\r\n\r\n            return encodeMethod.encode(URLRequest, parameters: parameters).0\r\n        }\r\n    }\r\n\r\nInstead of the call being a success, the response is:\r\n\r\n    response: Optional(<NSHTTPURLResponse: 0x7fcee15b34d0> { URL: https://apiurl } { status code: 400, headers {\r\n    \"Cache-Control\" = \"no-cache\";\r\n    \"Content-Length\" = 26;\r\n    \"Content-Type\" = \"application/json; charset=utf-8\";\r\n    Date = \"Tue, 15 Sep 2015 15:33:50 GMT\";\r\n    Expires = \"-1\";\r\n    Pragma = \"no-cache\";\r\n    Server = \"Microsoft-IIS/8.5\";\r\n    } })\r\n\r\nIs there code I'm not updating properly since I upgraded to Alamofire 2.0?"},"comment":{"url":"https://api.github.com/repos/Alamofire/Alamofire/issues/comments/140742830","html_url":"https://github.com/Alamofire/Alamofire/issues/773#issuecomment-140742830","issue_url":"https://api.github.com/repos/Alamofire/Alamofire/issues/773","id":140742830,"user":{"login":"mikewalkerjr","id":4707821,"avatar_url":"https://avatars.githubusercontent.com/u/4707821?v=3","gravatar_id":"","url":"https://api.github.com/users/mikewalkerjr","html_url":"https://github.com/mikewalkerjr","followers_url":"https://api.github.com/users/mikewalkerjr/followers","following_url":"https://api.github.com/users/mikewalkerjr/following{/other_user}","gists_url":"https://api.github.com/users/mikewalkerjr/gists{/gist_id}","starred_url":"https://api.github.com/users/mikewalkerjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikewalkerjr/subscriptions","organizations_url":"https://api.github.com/users/mikewalkerjr/orgs","repos_url":"https://api.github.com/users/mikewalkerjr/repos","events_url":"https://api.github.com/users/mikewalkerjr/events{/privacy}","received_events_url":"https://api.github.com/users/mikewalkerjr/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T13:30:16Z","updated_at":"2015-09-16T13:30:16Z","body":"@cnoon and @jshier, I posted on Stack Overflow http://stackoverflow.com/questions/32596031/put-request-failing-with-alamofire-2-0"}}