I'm stuck on the question of how to build up my objects and mapping to achieve something like this when putting data via the PUT-Method: "lastChanges/confirm"
The above PUT-Request accepts a body like this to confirm synchronization of box ids:
{ "synchronized_boxes": [47292,someOtherBoxId,..] }
I have tried building an Object like this:
@interface RPConfirmSync : NSObject
@property (nonatomic, retain) NSArray *synchronized_boxes;
@end
Before I send this Object I add some NSNumber Objects to the array.
The mapping I set up looks like this:
RKObjectMapping *confirmMapping = [RKObjectMapping mappingForClass:[RPConfirmSync class]];
[confirmMapping addAttributeMappingsFromArray:@[@"synchronized_boxes"]];
RKObjectMapping *requestMapping = [confirmMapping inverseMapping];
NSString *pathPattern = [NSString stringWithFormat:@"lastsync/confirm"];
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:requestMapping objectClass:[RPConfirmSync class] rootKeyPath:nil];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:confirmMapping pathPattern:pathPattern keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[self.objectManager addRequestDescriptor:requestDescriptor];
[self.objectManager addResponseDescriptor:responseDescriptor];
Now, when I execute the above PUT-Request and look at the request body, the RestKit Debug information shows me something weird like this:
request.body=synchronized_boxes[]=47292 //being sent to the server !ERROR!
which should be
request.body=synchronized_boxes[47292]
How do I have to set up my Object or is there something wrong with the mapping? I'm really stuck here, although I guess the answer is straight forward.