2

当我尝试发送 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}

我错过了什么吗?

4

2 回答 2

3

HTTP 状态代码 400 表示“错误请求”。您正在尝试访问格式错误的 URL,或者您正在访问的 URL 想要查看您未提供的请求中的某些内容。

于 2012-03-17T22:36:37.793 回答
0

发生此问题是因为在调用 Web 服务时未与服务器正确通信。如果你不断尝试同样的事情,你没有得到任何新的回应。请在下面的流程中休息,可能你会成功。

  • 1)注销并再次登录(高度优先)

  • 2)重新安装应用程序并再次检查(最后优先级)

于 2017-05-30T08:43:22.253 回答