当我尝试发送 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 表示“错误请求”。您正在尝试访问格式错误的网址,或者您正在访问的网址想要查看请求中您未提供的内容。
关于objective-c - NSLocalizedDescription=预期状态代码在 (200-299) 中,得到 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9754331/