我正在使用RestKit(v0.20.3),当我获得对GET HTTP请求的响应时,我无法解析它,因为我收到此错误:
Failed to parse response data: Loaded an unprocessable response (200)
with content type 'text/html' UserInfo=0x6c4a2b0
{NSErrorFailingURLKey=https://helloEverybody.com/, NSUnderlyingError=0x6c4a1e0
"The operation couldn’t be completed. (Cocoa error 3840.)"
这是我的代码:
[RKMIMETypeSerialization registerClass:[RKNSJSONSerialization class] forMIMEType:@"text/html"];
NSURL *baseUrl = [[NSURL alloc]initWithString:@"https://helloEverybody.com"];
RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:baseUrl];
[objectManager.HTTPClient setAuthorizationHeaderWithUsername:@"user" password:@"password"];
[objectManager setAcceptHeaderWithMIMEType:@"text/html"];
[objectManager getObjectsAtPath:@"" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"It worked!!: %@", [mappingResult firstObject]);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"It failed: %@", error);
}];
我已经阅读了很多类似的帖子,他们通常会修复此问题,将服务器响应更改为json,但我无法触及服务器。我需要解析这些“text / html”。
任何人都知道我该怎么做?
谢谢!