I am using Alamofire in my iOS app. I used post method along with parameters and all went well. Now i want to send a token as header but I am getting an error of Extra argument 'method' in call. I searched for the ways to send header in post request but only found the way I am already trying. What am I doing wrong? Did I miss anything? Here is my code in which I am sending post request.
let urlCreate = "#########"
Alamofire.request(urlCreate, method: .post, parameters: ["name" : adventureName, "lat" : lat, "long" : long], encoding: JSONEncoding.default, headers: ["jwtToken" : jwtToken]).responseJSON(completionHandler: { response in
switch response.result {
case .success:
print(response)
case .failure(let error):
print(error)
self.errorLabel.text = error as! String
}
})
I am using Swift 3, Xcode 8, Alamofire 4
Things i tried:
Clean the project and built again.
Removed the parameter encoding: JSONEncoding.default
Initialized parameters like let paramters = ["name" : adventureName, "lat" : lat, "long" : long] as [String : Any]
Specified the method method: HTTPMethod.post
way but still getting the same error.