Note that there are some explanatory texts on larger screens.

plurals
  1. PORestKit Mapping of Array with Ids for PUT Method
    primarykey
    data
    text
    <p>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"</p> <p>The above PUT-Request accepts a body like this to confirm synchronization of box ids:</p> <pre><code>{ "synchronized_boxes": [47292,someOtherBoxId,..] } </code></pre> <p>I have tried building an Object like this:</p> <pre><code>@interface RPConfirmSync : NSObject @property (nonatomic, retain) NSArray *synchronized_boxes; @end </code></pre> <p>Before I send this Object I add some NSNumber Objects to the array.</p> <p>The mapping I set up looks like this:</p> <pre><code>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]; </code></pre> <p>Now, when I execute the above PUT-Request and look at the request body, the RestKit Debug information shows me something weird like this:</p> <pre><code>request.body=synchronized_boxes[]=47292 //being sent to the server !ERROR! </code></pre> <p>which should be</p> <pre><code>request.body=synchronized_boxes[47292] </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload