Google Groups

RKParams question

Dave_C Apr 8, 2011 4:33 PM
Posted in group: RestKit
I am attempting to manually add a parameter within my object before it
is serialized and sent via PUT. e.g. I want to add provide a date
value anytime i encounter a createdOn == nil. Side note, if the value
is nil, the param is excluded from JSON payload (not sure i understand
where to control this). I'm using RKJSONSerialization via a
RKDynamicRouter subclass. Note 2: This is all in an effort to work
with non-string param types (NSDate, Int specifically).

The problem is that manipulating the params seems to change my content
type from JSON to Multipart form data.

For example, adding this to my model class:
-(void)willSendWithObjectLoader:(RKObjectLoader *)objectLoader{
        RKParams *params = [RKParams params];

        if(self.createdOn == nil)
                NSDate *now = [[NSDate alloc] init];
                NSData* createdOn_data = [NSData dataWithBytes:&now
                [params setData:createdOn_data forParam:@"createdOn"];
        objectLoader.params = params;


Results in a change in the content/type from application/json to

Thank You