RestKit 0.20 - The expected content type (null)

Restkit 0.20

Does anyone know why I get this output on every call? Any suggestions on tracking it? I see json payload on debug output.

error=Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type (null), got application/json" UserInfo=0x9187fe0 {NSLocalizedRecoverySuggestion={ 

I am calling

 [manager getObjectsAtPath:@"/customers" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { NSArray* statuses = [mappingResult array]; NSLog(@"Loaded customers: %@", statuses); } failure:^(RKObjectRequestOperation *operation, NSError *error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; NSLog(@"Customer Error: %@", error); }]; 

and my display code

 @interface DataCustomers : NSObject @property (nonatomic, copy) NSString* customerid; @property (nonatomic, copy) NSString* firstname; @property (nonatomic, copy) NSString* lastname; @property (nonatomic, copy) NSString* email; @end RKObjectMapping *map = [RKObjectMapping mappingForClass:[DataCustomers class]]; [map addAttributeMappingsFromDictionary:@{ @"id" : @"customerid", @"firstname" : @"firstname", @"lastname" : @"lastname", @"email" : @"email"}]; [manager addResponseDescriptor: [RKResponseDescriptor responseDescriptorWithMapping:map pathPattern:@"/customers" keyPath:@"customers" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]]; 
+4
source share
2 answers

There was some strange conflict with the library, which completely confused AFNetwork.

In addition to removing this problem, I added nil to pathPattern.

+1
source

Do you set your willingness to handle the content type correctly?

Try adding this to your AppDelegate:

 #import "RKMIMETypeSerialization.h" #import "RKNSJSONSerialization.h" [RKMIMETypeSerialization registerClass:[RKNSJSONSerialization class] forMIMEType:@"application/json"]; 
+2
source

Source: https://habr.com/ru/post/1447687/


All Articles