Here是我需要下载到我的应用程序的内容。
这就是我请求的方式:
GET("identifiers/pl-normal.json", parameters: nil, progress: nil, success: { sessionDataTask, response in
}) { sessionDataTask, error in
completionBlock(error)
}
URL 请求正确:GET 可选(http://www.taboo.blue-world.pl/api/identifiers/pl-normal.json)
但是 failure
block 被调用,为什么?
最佳答案
如果无法正确解析网络请求的结果,将在AFNetworking
中调用错误 block 。换句话说,这是一个序列化错误。您获取的内容似乎不是格式正确的 json。通过 json linter 运行您的服务器响应并确保它有效,您应该已准备就绪。
如果这不起作用,请尝试在序列化程序中添加 text/html 作为可接受的内容类型,如此处所述 - Request failed: unacceptable content-type: text/html using AFNetworking 2.0
关于ios - 如何使用AFNetworking获取URL的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34683875/