休息套件 0.20
有谁知道为什么我每次通话都会得到这个输出?关于追踪它有什么建议吗?我可以在调试输出中看到 json 有效负载。
error=Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type (null), got application/json" UserInfo=0x9187fe0 {NSLocalizedRecoverySuggestion={
我正在打的电话是
[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);
}];
我的映射代码是
@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)]];