I try use shared session to talk to a http server. In xcode playground,
import Foundation
var session = NSURLSession.sharedSession()
var url = NSURL(string: "http://api.zoomeye.org/user/login")
var _data: NSData?
var _response: NSURLResponse?
var _error: NSError?
var dataTask = session.dataTaskWithURL(url!, completionHandler: {(data, response, error) in
_data = data
_response = response
_error = error
})
dataTask.resume()
print(_data)
print(_response)
print(_error)
the printed results are nil, it shouldn't be nil.
Use chrome to access the url, message in entity body is this,
{"url": "https://www.zoomeye.org/api/doc", "message": "request failed, the specified method was not allowed", "error": "method_not_allowed"}
Where are mistakes? and how to fix it?