This code works with other URL's, but not with this one. It always returns nil with "contentsOfURL". Why?
var url = NSURL(string: "http://www.bsnpr.com/api/standing.asp?serie=1&liga=1&y=2015")
var err: NSError?
var data = NSData(contentsOfURL: url!, options: nil, error: &err)
"err" delivers the message:
"Optional(Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)" UserInfo=0x7f8f32c2e1e0 {NSURL=http://www.bsnpr.com/api/standing.asp?serie=1&liga=1&y=2015})"
Any ideas? Thanks in advance.
Your server delivers data with
Transfer-Encoding
set tochunked
, andNSData
doesn't like it.You can get your data with a REST framework like Alamofire: