Reputation: 487
I'm trying to use Alamofire to do a GET request for my iOS app, but I don't really know how to enter my username and password.
The cURL command that ran successfully was
curl -k -u user:pw https://url/cli/method
and it returned the correct JSON
for Alamofire I tried
Alamofire.request(.GET, self.baseURL + method, parameters: params).responseJSON { (_, _, JSON, _) in
println(JSON)
where baseURL + method is https://url/rest/method
and params is
let params = [
"username" : self.username.text,
"password" : self.password.text
]
but when I try it it says that
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
What am I doing incorrectly?
Upvotes: 3
Views: 2286
Reputation: 487
Apparently there is a thing for this in Alamofire. I need to do...
Alamofire.request(.GET, self.baseURL + method, parameters: nil)
.authenticate(user: self.username.text, password: self.password.text)
.responseJSON { (_, _, JSON, _) in
println(JSON)
}
To authenticate myself.
Upvotes: 7