2

iPhone5 で iOS9 をテストしていたところ、API 呼び出しが実行されないことに気付きました。呼び出しを行いましたが、バックエンドに何も送信されません。

これは私の方法です:

-(void)placePostRequest:(NSString *)action withData:(NSDictionary *)dataToSend withHandler:(void (^)(NSURLResponse *response, NSData *data, NSError *error))ourBlock {
    NSString *urlString = [NSString stringWithFormat:@"%@/%@", URL_API, action];
    NSLog(urlString);

    NSURL *url = [NSURL URLWithString:urlString];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

    // Creamos el JSON desde el data
    NSError *error;

    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataToSend options:0 error:&error];

    NSString *jsonString;
    if (! jsonData) {
        NSLog(@"Got an error: %@", error);
    } else {
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

        NSData *requestData = [NSData dataWithBytes:[jsonString UTF8String] length:[jsonString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];

        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        [request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
        [request setHTTPBody: requestData];

        [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:ourBlock];
    }
}

HTTPResponse は nil で、コード 0:

ここに画像の説明を入力

これは私が受け取ったものです:

2015-06-15 13:40:48.176 myProject[291:33222] CFNetwork SSLHandshake failed (-9824)
2015-06-15 13:40:48.181 myProject[291:33222] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)
4

0 に答える 0