Request Failed with Error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/javascript",
"application/json",
"text/json"
)}, got text/html" UserInfo=0x7fe649fbd240 {NSLocalizedRecoverySuggestion={"code":510,"message":"\u77ed\u4fe1\u53d1\u9001\u5931\u8d25","token":""}, NSErrorFailingURLKey=http://192.168.1.10/ebi/index.php/c_user/create_code, AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x7fe649c7e640>
解决方案:
修改
[httpClient setDefaultHeader:@"Accept" value:@"text/json"];
在代码中加入
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
是我亲自尝试过的,希望能解决你的问题!
本文提供了一种解决AFNetworking错误的方法,该错误提示预期的内容类型为JavaScript、JSON或JSON文本,但实际返回的是HTML。通过在代码中设置默认接受的内容类型为JSON,并添加一个额外的配置来解决此问题。

994

被折叠的 条评论
为什么被折叠?



