Nikitin Roman Nikitin Roman - 4 months ago 89
Swift Question

Swift Alamofire POST request becomes GET

That's the code I'm using to make POST request to my Flask server in localhost:

func data_request() {
let url:NSURL = NSURL(string: "")!

Alamofire.request(.POST, url, parameters: ["login":"login", "password" : "12345"]).responseJSON { response in
switch response.result {
case .Success:
NSLog("Validation Successful")
case .Failure(let error):
NSLog("\(error), \(String(data:!, encoding: NSUTF8StringEncoding))")
if (response.result.value as? [String: AnyObject]) != nil{

But it sends GET request! Both server and local proxy tell it was GET request - that's what Burp has intercepted:

GET /api/register/ HTTP/1.1
Accept: */*
User-Agent: Project Manager/Roman-Nikitin.Project-Manager (1; OS X 10.11.3)
Accept-Language: en;q=1.0, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5
Accept-Encoding: gzip;q=1.0, compress;q=0.5
Connection: close


I had the same problem, you just have to put / at the end of URL. Problem is in Alamofire, I think. It works weird with normal server redirections from to