objective c - posting array of dictionaries with Restkit 0.20 -


im having issues getting function correctly.

i have mapped key value pairs of json payload inject request end failure on each post.

the following lines show me creating reqeust:

rkobjectmapping *requestmapping = [wdmappingprovider createreginitrequestticketmapping];     rkrequestdescriptor *requestdescriptor = [rkrequestdescriptor requestdescriptorwithmapping:[requestmapping inversemapping] objectclass:[wdticketsmodel class] rootkeypath:nil]; [registrationmanager addrequestdescriptor:requestdescriptor]; 

i create path post , put in data post request:

//make object params     wdregistrationinitializerequestmodel *requestmodel  = [[wdregistrationinitializerequestmodel alloc] init];      requestmodel.eventid = [params objectforkey:@"eventid"];     requestmodel.arrayofticketdictionaries  = [params objectforkey:@"arrayofticketdictionaries"];      nsstring *postpath = [nsstring stringwithformat:@"api/v1/registrations/initialize?eventid=%@", requestmodel.eventid];      //post object (aka interest json payload)     [registrationmanager postobject:requestmodel.arrayofticketdictionaries path:postpath parameters:nil success:^(rkobjectrequestoperation *operation, rkmappingresult *result){ ... 

at point end in failure block of postobject method.

my mapping made [wdmappingprovider createreginitrequestticketmapping] looks this:

+(rkobjectmapping *)createreginitrequestticketmapping {     rkobjectmapping *reginitrequestmapping = [rkobjectmapping mappingforclass:[wdticketsmodel class]];     [reginitrequestmapping addattributemappingsfromdictionary:      @{         @"quantity" : @"quantity",         @"ticketid":@"mainid"      }];       return reginitrequestmapping; } 

the arrayofticketdictionaries looks this:

[{"quantity":1,"ticketid":1604},{"quantity":1,"ticketid":1605},{"quantity":1,"ticketid":1606}] 

any thoughts?

i think it's because you're missing rkresponsedescriptor part. try adding one:

// in 2xx nsindexset *statuscodes =   rkstatuscodeindexsetforclass(rkstatuscodeclasssuccessful); rkresponsedescriptor *responsedescriptor =   [rkresponsedescriptor    responsedescriptorwithmapping:requestmapping    method:rkrequestmethodany    pathpattern:nil    keypath:nil    statuscodes:statuscodes]; [registrationmanager addresponsedescriptor: responsedescriptor]; 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -