各位大家好!
我只有dependencies
的3周,但总是xcode返回错误。
[3](null)@" NSLocalizedDescription" :@"请求失败:不可接受 content-type:application / json"
主要功能是:
NSURLSessionDataTask
主要目标是Zyncro的atack API,并在json中返回信息。
生成对象文档的功能是:
+ (Document * ) getDocumentInfo: (NSString *) grupo documento:(NSString *) documento {
BDBOAuth1SessionManager *sesion = [manager getSessionManager];
sesion.responseSerializer = [AFHTTPResponseSerializer new];
sesion.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/plain",@"text/html", nil];
static NSMutableDictionary *json;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
NSString *timelinePath = [NSString stringWithFormat:@"/api/v1/rest/groups/%@/document/%@",grupo,documento];
static NSString *check;
sesion.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
AFHTTPRequestOperation *operation = [sesion GET:timelinePath
parameters:@{}
success:^(NSURLSessionDataTask *task, id requestReply) {
NSString *requestReply2 = [[NSString alloc] initWithBytes:[requestReply bytes] length:[requestReply length] encoding:NSUTF8StringEncoding];
NSData *data = [requestReply2 dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSError * error;
json = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error: &error];
if (![requestReply2 isEqualToString:@""]) {
if ([[json objectForKey:@"result"] isEqualToString:@"OK"]) {
check = @"YES";
}
}
dispatch_semaphore_signal(semaphore);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
//nslo(nil, error);
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
if ([check isEqualToString:@"YES"]) {
return[Document generateDocument:[json objectForKey:@"object"]];
//return fichero;
}else{
return nil;
}
}
我的问题是为什么如果我把可接受的内容:application / json,因为错误在应用程序/ json谢谢你们
感谢所有