美文网首页IOS 那些事
关于 http请求返回 Request failed: meth

关于 http请求返回 Request failed: meth

作者: Hello_Kugou | 来源:发表于2017-01-19 17:45 被阅读106次

第一种情况:遇到405请求错误。提示:

NSLocalizedDescription=Request failed: method not allowed (405)。
解决方案:405请求方法不被允许。这时候应该检查请求方法是否正确,页面应该用GET请求还是POST请求。例如在请求微博access_token的时候虽然不需要发送数据但这个页面却要求使用POST请求。

第二种情况:
使用AFNetwork进行HTTP请求遇到如下提示信息错误:
NSLocalizedDescription=Request failed: unacceptable
content-type: text/plain。

解决方案:这里的错误提示是因为AFHTTPRequestOperationManager默认的http请求头没有包含text/plain格式。应使用
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/plain"];手动添加。当然也可能会出现text/html类型的。解决方案同理手动添加。

相关文章

网友评论

    本文标题:关于 http请求返回 Request failed: meth

    本文链接:https://www.haomeiwen.com/subject/ttiibttx.html