Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. Alamofire.request(.POST, "http://www.webapi.com?path=Login", parameters: ["username": "myname", "password": "mypass"]).responseJSON { response in
  2. // do something with returned data ...
  3. }
  4.  
  5. let request = NSMutableURLRequest(URL: NSURL(string:"http://www.webapi.com?path=Login")!)
  6.  
  7. let bodyData = "username=myname&password=mypass"
  8. request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding)
  9. request.HTTPMethod = "POST"
  10.  
  11. let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
  12.  
  13. session.dataTaskWithRequest(request) { (data, response, error) -> Void in
  14.  
  15. // do something with returned data...
  16.  
  17. }.resume()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement