Interesting situation: no errors, 200 response, yet no data returned

18 views
Skip to first unread message

Fletcher Bumpus

unread,
Apr 22, 2015, 6:18:34 PM4/22/15
to res...@googlegroups.com
Hi everyone,

I've spent the day banging my head against my Mac with this issue, and haven't found the answer yet.  Can you help?  Please bear in mind that I am a new RestKit developer.

Using the latest version of RestKit, I have been converting over an app from using SOAP to using REST using, of course, RestKit.

I've successfully converted over three calls thus far.  They gather data, they return with mapped data, and everyone's happy.

And then came this issue.

I make the call:

RKObjectRquestOperation *operation = [manager objectRequestOperationWithRequest: request success:nil failure: nil];
[operation start];
[operation waitUntilFinished[;

The call comes back successfully, checking thusly:

if(operation.error == nil)
{
   RKMappingResult *mappingResult = operation.mappingResult;
   HESFpConPolicy * model = mappingResult.array[0];
   <do stuff...>
}


When I reach the above lines, mappingResult has 0 objects.  I verified via WireShark that the call was made and a 200 result returned with proper JSON data.  No errors have been returned via RestKit, and with debugging on RestKit is showing all good stuff...it's showing proper mapping results, successful mapping etc.

Still, when I try to reference the results using the above code, nothing is showing.

I'm sure there's something I'm missing, and being a new RestKit developer isn't helping.  What could I be missing?

I should note that the same code worked in another call, with data returned... the only difference is in the data returned.

Thanks in advance!


Oli Griffiths

unread,
Apr 22, 2015, 9:16:50 PM4/22/15
to res...@googlegroups.com
Hi Fletcher

In order for us to help you with this, can you post your RKMapping definitions so that we may examine them and work out the issue. Are you able to post the URL’s you’re also working with.

Thanks

Oli

Fletcher Bumpus

unread,
Apr 23, 2015, 9:29:39 AM4/23/15
to res...@googlegroups.com
Hi Oli,

Thank for responding!  Here's the method:

+(void) getFPConPolicy

    {

        

        RKLogConfigureByName("RestKit", RKLogLevelWarning);

        RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);

        RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);

        NSMutableURLRequest *request = [[HESMAXHttpClient sharedClient] requestWithMethod:@"GET" path:@"/api/RemoteCheck/GetFpConPolicy" parameters:nil];

        RKObjectManager *manager = [RKObjectManager sharedManager];

        manager.requestSerializationMIMEType = RKMIMETypeJSON;

        NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);

        RKObjectMapping* responseMapping = [RKObjectMapping mappingForClass:[HESFpConPolicy class]];

        [responseMapping addAttributeMappingsFromArray: @[@"FP_LEVEL",@"DBIDS_ALLOWED",@"MAX_BRIDGE",@"CAC_SCAN",@"STATE_ID",@"PIV_ENABLED",@"CAC_ENABLED",@"TWIC_ENABLED",@"PIN_REQUIRED",@"FP_REQUIRED",@"MANUAL_ALLOWED"]];

        [responseMapping addAttributeMappingsFromDictionary:@{@"fpconresults.FP_LEVEL" : @"FpConLevel",

                                                              @"fpconresults.DBIDS_ALLOWED" : @"DbidsAllowed",

                                                              @"fpconresults.MAX_BRIDGE" : @"MaxIdScanAllowed" ,

                                                              @"fpconresults.CAC_SCAN" : @"CacScanAllowed" ,

                                                              @"fpconresults.STATE_ID" : @"StateIdScanAllowed",

                                                              @"fpconresults.PIV_ENABLED" : @"PivReadAllowed",

                                                              @"fpconresults.CAC_ENABLED" : @"CacReadAllowed",

                                                              @"fpconresults.TWIC_ENABLED" : @"TwicReadAllowed",

                                                              @"fpconresults.PIN_REQUIRED" : @"PinRequired",

                                                              @"fpconresults.FP_REQUIRED" : @"FingerPrintRequired",

                                                              @"fpconresults.MANUAL_ALLOWED":@"ManualAllowed"

                                                              }];

        RKResponseDescriptor *responseDescriptor =

        [RKResponseDescriptor responseDescriptorWithMapping:responseMapping

                                                     method:RKRequestMethodGET

                                                pathPattern:@"/api/RemoteCheck/GetFpConPolicy"

                                                    keyPath:@"fpconresults"

                                                statusCodes:statusCodes];

        [manager addResponseDescriptor:responseDescriptor];

        RKObjectRequestOperation *operation = [manager objectRequestOperationWithRequest:request success:nil failure:nil];

        [operation start];

        [operation waitUntilFinished];

        if (operation.error == nil)

        {

            NSError *error;

            RKMappingResult *mappingResult = operation.mappingResult;

            HESFpConPolicy * model = mappingResult.array[0];

            if (error != nil)

            {

                RKLogError(@"Failure calling GetFpConPolicy");

            }

            else

            {

                RKLogInfo(@"Good Return from GetFpConPolicy");

                [self setFpConPolicyValues: model];

            }

        }

        else

        {

            RKLogError(@"Failure calling GetFpConPolicy");

            [self setFPConPolicyValuesError];

        }

    }


Here's the declaration of HESFpConPolicy:

@interface HESFpConPolicy : NSObject

@property (nonatomic, strong) NSString *CacScanAllowed;

@property (nonatomic, strong) NSString *StateIdScanAllowed;

@property (nonatomic, strong) NSString *MaxIdScanAllowed;

@property (nonatomic, strong) NSString *CacReadAllowed;

@property (nonatomic, strong) NSString *PivReadAllowed;

@property (nonatomic, strong) NSString *TwicReadAllowed;

@property (nonatomic, strong) NSString *PinRequired;

@property (nonatomic, strong) NSString *FingerPrintRequired;

@property (nonatomic, strong) NSString *DbidsAllowed;

@property (nonatomic, strong) NSString *FpConLevel;

@property  (nonatomic, strong) NSString *ManualAllowed;

@end


I can't provide the URL we're hitting publicly, but I'll be happy to provide it to you in a private email.  When the call is made, the following is the JSON data return:

{
fpconresults
{
FP_LEVEL"ALPHA"
DBIDS_ALLOWED"FALSE"
MAX_BRIDGE"TRUE"
CAC_SCAN"TRUE"
STATE_ID"TRUE"
PIV_ENABLED"TRUE"
CAC_ENABLED"TRUE"
TWIC_ENABLED"FALSE"
PIN_REQUIRED"TRUE"
FP_REQUIRED"FALSE"
MANUAL_ALLOWED"FALSE"
}
-


}


in the above code, mappingResult always comes back with 0 objects.

Fletcher Bumpus

unread,
Apr 23, 2015, 11:27:59 AM4/23/15
to res...@googlegroups.com
Problem resolved.  

Resolution?  A simple reboot apparently solved the issue.  Sorry for the waste of time guys.
Reply all
Reply to author
Forward
0 new messages