2

RestKit 0.20.3 を使用してオブジェクトをマップしようとしていますが、これらのログを数日間記録しています。

2013-08-12 18:32:08.158 MyAppIphone[848:5703] E restkit.network:RKResponseMapperOperation.m:304 Failed to parse response data: Loaded an unprocessable response (200) with content type 'application/json'

2013-08-12 18:32:08.174 MyAppIphone[848:5703] E restkit.network:RKObjectRequestOperation.m:238 POST 'myUrl' (200 OK / 0 objects) 

[request=0.1305s mapping=0.0000s total=5.6390s]:
error=Error Domain=org.restkit.RestKit.ErrorDomain Code=-1017 "Loaded an unprocessable response (200) with content type 'application/json'" 

UserInfo=0x1ed5a500 {NSErrorFailingURLKey=myUrl, NSUnderlyingError=0x1ed5b240 "The operation couldn’t be completed. (Cocoa error 3840.)", NSLocalizedDescription=Loaded an unprocessable response (200) with content type 'application/json'}

response.body={"my json content"}

MyData クラスは次のとおりです。

#import <Foundation/Foundation.h>

@interface MyData : NSObject

@property (nonatomic, retain) NSString *criterias;

@end

マッパーをセットアップする方法は次のとおりです。

- (RKResponseDescriptor*) getDataMapping
{
    // Mapping
    RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[MyData class]];
    [mapping addAttributeMappingsFromDictionary:@{
     @"criteriasHeader":        @"criteriasHeader"
     }];

    // Status code
    NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);

    // Descriptior
    return [RKResponseDescriptor responseDescriptorWithMapping:mapping method:RKRequestMethodPOST pathPattern:nil keyPath:@"regions" statusCodes:statusCodes];
}

ここで私のリクエスト機能:

- (void) runRequestWithType:(RequestType)type baseUrl:(NSString *)baseUrlString path:(NSString *)path parameters:(NSDictionary *)parameters mapping:(RKResponseDescriptor *) descriptor
{
    // Print heeader and body from the request and the response
    RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
    RKLogConfigureByName("Restkit/Network", RKLogLevelDebug);
    RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
    RKLogConfigureByName("Restkit/ObjectMapping", RKLogLevelDebug);

    // Set up the base url
    NSURL *baseUrl = [NSURL URLWithString:baseUrlString];

    //Run request in block
    RKObjectManager *manager = [RKObjectManager managerWithBaseURL:baseUrl];
    [manager addResponseDescriptorsFromArray:@[descriptor]];

    [manager.router.routeSet addRoute:[RKRoute routeWithClass:[MyData class] pathPattern:path method:RKRequestMethodPOST]];
    //[manager getObjectsAtPath:path parameters:parameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
    [manager postObject:nil path:path parameters:parameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
        if ([self.delegate respondsToSelector:@selector(requestDidSucceedWithType:andResponse:)]) {
            [self.delegate requestDidSucceedWithType:type andResponse:[mappingResult firstObject]];
        }
    } failure:^(RKObjectRequestOperation *operation, NSError *error) {
        if ([self.delegate respondsToSelector:@selector(requestDidFailWithError:andError:)]) {
            [self.delegate requestDidFailWithType:type andError:error];
        }
    }];
}

PS: 短い JSON で試してみましたが、うまくいきました。

私は何か間違ったことをしましたか?

助けてくれませんか、ありがとう。

4

2 に答える 2