当我尝试发送 HTTP 请求以获取 JSON 响应时:
NSURL *url = [NSURL URLWithString"http://data.mycitydataset.gov/api/views/INLINE/rows.json?method=index"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"Success");
} failure:^(NSURLRequest* req,NSHTTPURLResponse *req2, NSError *error,id mex) {
NSLog(@"%@", [error description]);
}];
[operation start];
我在日志上得到了这个堆栈:
Error Domain=com.alamofire.networking.error Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0x7bb31b0 {NSErrorFailingURLKey=http://data.baltimorecity.gov/api/views/INLINE/rows.json?method=index, NSLocalizedDescription=Expected status code in (200-299), got 400}
我错过了什么吗?
HTTP 状态码 400 表示“错误请求”。您正在尝试访问格式错误的 URL,或者您正在访问的 URL 希望在请求中看到您未提供的内容。
关于objective-c - NSLocalizedDescription=(200-299)中的预期状态码,得到 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9754331/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |