To make API (Web Service ) call in Swift you can do,
var params = [“MIN”:”f8d16d98ad12acdbbe1de647414495ec”, “MobileType”:”IOS”,”format”:”json”,”OperatorID”:”500200000000010025″] as Dictionary // Its the parameters required in the webservice.
var request = NSMutableURLRequest(URL: NSURL(string: kDataURL)) // Here kDataURL is the marco for URL.
var session = NSURLSession.sharedSession()
request.HTTPMethod = “POST”
var err: NSError?
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: nil, error: &err)
request.addValue(“application/json”, forHTTPHeaderField: “Content-Type”)
request.addValue(“application/json”, forHTTPHeaderField: “Accept”)
var task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
// println(“Response: \(response)”)
var strData = NSString(data: data, encoding: NSUTF8StringEncoding)
println(“Body: \(strData)”)
var err: NSError?
var json2 = NSJSONSerialization.JSONObjectWithData(strData.dataUsingEncoding(NSUTF8StringEncoding), options: .MutableLeaves, error:&err1 ) as NSDictionary
println(“json1\(json2)”)