AFNetworking を使用してサーバーから JSON データを取得していますが、HTML と次のようなエラーしか返されません。
Expected content type {(
"text/json",
"application/json",
"text/javascript"
)}, got text/html, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x7592470>}
コードは次のとおりです。
NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:3000/games"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation;
operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *req, NSHTTPURLResponse *response, id jsonObject){
NSLog(@"Response: %@", jsonObject);
}
failure:^(NSURLRequest *req, NSHTTPURLResponse *response, NSError *error, id jsonObject){
NSLog(@"Error: %@", error);
}];
[operation start];
Rails を使用しており、curl でページにアクセスすると、サーバーから JSON が返されます。application/json を強制的に要求したいのですが、これは間違っていますか?