I'm building a new IOS 10 application and I need to call a rest service which uses classic HTTP basic authentication (prompts for username/password when using a brower). The only code I've found online uses Swift 2 but I'm using Swift 3. Could someone please finish the code <at line 14>?
let username = "username"
let password = "password"
let loginString = String(format: "%@:%@", username, password)
let loginData = loginString.data(using: String.Encoding.utf8)!
let base64LoginString = loginData.base64EncodedString()
let url = URL(string: "http://192.168.1.2/rest")
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
**** WHAT GOES HERE ****?????The code compiles okay but what do I call on the URLSession object to call the rest service and fetch the data (which is XML)?
Thanks!