RestKit中的MIME类型“text / html”的解析器

时间:2013-11-19 17:23:53

标签: ios restkit restkit-0.20

我正在使用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”。

任何人都知道我该怎么做?

谢谢!

0 个答案:

没有答案