didFailWithError: Error Domain = kCFErrorDomainCFNetwork Code = 303 «Операция не может быть завершена при запросе GET

Я получил следующую ошибку, когда я вызываю свой веб-сервис.

didFailWithError: Error Domain=kCFErrorDomainCFNetwork Code=303 "Операция не может быть завершена. (kCFErrorDomainCFNetwork ошибка 303.)" UserInfo=0x16e505b0 {NSErrorFailingURLKey=http://trac.app.com/api/v1/engine/chat/, NSErrorFailingURLStringKey=http://trac.app.com/api/v1/engine/chat/}
Мой исходный код выглядит следующим образом:< br> webservice.m

-(void)callChatWebservice:(NSString *)parameter
{
    NSString *requestString =[NSString stringWithFormat:@"http://trac.app.com/api/v1/engine/chat/"];

    //NSString *jsonString = [NSString stringWithFormat:@"{\"q\":\"%@\",\"uid\":\"%@\"}",[parameter valueForKey:@"q"],[parameter valueForKey:@"uid"]];

    //NSString *jsonString = [NSString stringWithFormat:@"{\"uid\":\"%@\"}",[parameter valueForKey:@"uid"]];
    NSString *jsonString = [NSString stringWithFormat:@"{\"uid\":\"%@\"}",parameter ];
    //NSString *jsonString = [NSString stringWithFormat:@"{\"username\":\"%@\",\"email\":\"%@\",\"password1\":\"%@\",\"password2\":\"%@\",\"location\":[%@,%@]}",[parameter valueForKey:@"username"],[parameter valueForKey:@"email"],[parameter valueForKey:@"password1"],[parameter valueForKey:@"password2"],[parameter valueForKey:@"latitude"],[parameter valueForKey:@"longitude"]];

    NSLog(@"JSON String: %@",jsonString);
    //NSLog(@"Request URL:  %@", requestString);
    NSData *jsonData = [NSData dataWithBytes: [jsonString UTF8String] length: [jsonString length]];


    NSURL *url = [NSURL URLWithString:requestString];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"GET"];
    [request setHTTPBody: jsonData];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[jsonData length]] forHTTPHeaderField:@"Content-Length"];
    NSString *strAuth = [NSString stringWithFormat:@"wfkey %@:%@",kAppID,kAppKey];
    [request setValue:strAuth forHTTPHeaderField:@"Authorization"];
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if(theConnection) {
        webData = [[NSMutableData alloc] init];
    }
    else {
        NSLog(@"theConnection is NULL");
    }
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [webData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    //    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    //    [appDelegate hideProgressHUD];
    NSLog(@"didFailWithError: %@",[error description]);
    //    [CommonUtils webserviceError];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"connectionDidFinishLoading Chat");
    NSError *jsonError = nil;
    NSDictionary *dictionaryJSON = [NSJSONSerialization JSONObjectWithData:webData options:kNilOptions error:&jsonError];
    NSLog(@"Response: %@",dictionaryJSON);
    [[NSNotificationCenter defaultCenter] postNotificationName:kChatSuccessNotification object:nil userInfo:dictionaryJSON];
}

@end  

вызов веб-сервиса: viewcontroler1

NSMutableDictionary *dictRequest = [[NSMutableDictionary alloc] init];
    [dictRequest setValue:@"54783e4014e5f50007d50214" forKey:@"uid"];
    //[dictRequest setValue:@"ed9d61a838ae8ac83d5a7cabbc4e5779" forKey:@"app_key"];

    NSString *requestString = [CommonUtils encodeDictionary:dictRequest];
    // NSString *requestString = [CommonUtils getJSONString:dictRequest withPrettyPrint:NO];
    NSLog(@"requestString: %@",requestString);

    WebserviceForChat *webserviceChat = [[WebserviceForChat alloc] init];
    [webserviceChat callChatWebservice:requestString];  

Пожалуйста, помогите мне решить эту проблему.


person Mihir Oza    schedule 12.12.2014    source источник
comment
Воспользуйтесь поиском. Это экономит нам обоим время.   -  person Droppy    schedule 12.12.2014
comment
см. также это /а>   -  person Suhit Patil    schedule 12.12.2014
comment
Я видел эту ссылку, но она у меня не работает. любое другое предложение???   -  person Mihir Oza    schedule 12.12.2014
comment
попробуйте отладить свой URL-адрес в каком-нибудь инструменте, таком как Charles или Postman   -  person Suhit Patil    schedule 12.12.2014