Categories
ios swift

Making an HTTP POST Request in Swift

In this example I will be uploading an image to a node.js server. func makePostRequest(){ // create a instantiate a session let session = NSURLSession.sharedSession() // set url to POST to var url = NSURL(string: “http://yourdomain.com/post”) // create the request object var request = NSMutableURLRequest(URL: url!) request.HTTPMethod = “POST” request.HTTPBody = YOUR_REQUEST_BODY // set up the […]