Reputation: 2074
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: "http://192.168.1.192:9880/api/register")!
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: response.data!, encoding: NSUTF8StringEncoding))")
return
}
if (response.result.value as? [String: AnyObject]) != nil{
print(response.result.value)
}
}
}
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
Host: 192.168.1.192:9880
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
Upvotes: 3
Views: 985
Reputation: 2339
For anyone getting here because they have the same problem (like me): In my case, I already had a /
at the end and I had to remove it.
Based on this answer, it seems to be the server redirecting the original POST request to a GET request. So either figure out what your server requires (trailing slash or no), or set up the server like in the linked answer.
Upvotes: 1
Reputation:
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 www.domain.com/something
to www.domain.com/something/
Upvotes: 7