gpt4 book ai didi

ios - "Request failed: unacceptable content-type: text/html"使用 AFNetworking 2.0

转载 作者:行者123 更新时间:2023-11-28 17:59:38 24 4
gpt4 key购买 nike

我正在尝试下面的代码,但它给出了错误:

{    
NSURL *url = [NSURL URLWithString:@"http://ielmo.xtreemhost.com/array.php"];
NSURLRequest *urlRequest =[[NSURLRequest alloc]initWithURL:url];
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
_imV.image = responseObject;

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
}];
[requestOperation start];
}

请帮助我解决 “请求失败: Not Acceptable 内容类型:text/html” 错误。

最佳答案

请尝试以下代码:

manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

关于ios - "Request failed: unacceptable content-type: text/html"使用 AFNetworking 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26756258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com