次のような JSON 応答を取得するために HTTP 要求を送信しようとすると:
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}
何か不足していますか?