AFNetworkingでリクエストを送ろうとしているのですが、リクエストは良いのですが「ネットワーク接続が失われました」と出て困っています。クライアントでリクエストを送信しようとしていますが、適切な応答が得られています。
リクエストの詳細は次のとおりです。 URL: https://www.ez-point.com/search メソッド: GET 認証ヘッダー: xxxxxxxxxxxxxxx リクエスト ペイロード: "search_text":"value"
私が使用しているコードは次のとおりです。
NSURL *url = [[NSURL alloc] initWithString:@"https://www.ez-point.com/search"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setValue:@"xxxxxxx" forHTTPHeaderField:@"Authorization" ];
[request setHTTPMethod:@"GET"];
NSMutableDictionary *jsonDic = [[NSMutableDictionary alloc]init];
[jsonDic setValue:@"UJO526" forKey:@"search_text" ];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDic options:NSJSONWritingPrettyPrinted error:nil];
[request setHTTPBody:jsonData];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
AFJSONRequestOperation *operation =
[AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSArray *searchResults = JSON;
if ([searchResults count] == 1){
id result = [searchResults objectAtIndex:0];
double latitude = [[result valueForKey:@"latitude"] doubleValue];
double longitude = [[result valueForKey:@"longitude"] doubleValue];
NSString *ezPoint = [result valueForKey:@"value"];
NSString *tags = [result valueForKey:@"tags"];
[self setAnnotation:latitude ForLongitude:longitude withEZPoint:ezPoint WithTags:tags];
}
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
}
];
[operation start];
私が得ているエラーは次のとおりです。
2013-11-04 15:01:05.143 EZ-POINT[4074:c07] E restkit.network:RKObjectRequestOperation.m:209 GET ' https://www.ez-point.com/search ' (0) [2.8806 s ]: エラー Domain=NSURLErrorDomain Code=-1005 「ネットワーク接続が失われました。」UserInfo=0x88b5c30 {NSErrorFailingURLStringKey= https://www.ez-point.com/search , NSErrorFailingURLKey= https://www.ez-point.com/search , NSLocalizedDescription=ネットワーク接続が失われました., NSUnderlyingError=0x1bc83790 "ネットワーク接続が失われました。"}
REST クライアントでは、https ://www.ez-point.com/search でパラメーター Authorization:xxxxxx と Request Payload search_text: UJO526 を使用して GET を実行しています。