AlejoVinueza AlejoVinueza - 2 months ago 25
iOS Question

Restkit url mapping in POST

I want to POST this URL documents/:ID/resend
and body request

{
"resend":{
"email": "foo@example.com"
}
}


and response

{
"result":{
"code": "123",
"message": "foo"
}
}


I did my request and respond descriptors and this route:

RKRoute *documentResendRoute = [RKRoute routeWithClass:[LDocument class]
pathPattern:@"documents/:ID/resend"
method:RKRequestMethodPOST];


and when I'm posting the document object

[[RKObjectManager sharedManager] postObject:self
path:@"documents/:ID/resend"
parameters:queryParams
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
//success code
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
//failure code
}];


Restkit doesn't map the :ID in the URL. It should result something like this "documents/880/resend" but at logs I can see "documents/:ID/resend" and the call fail.

LDocument has the ID property.

What did I miss? or How should I do this?

Thanks, Alejandro

Answer

When you call postObject you shouldn't be specifying the path, if you do this the router won't be used and the parameter not injected. Just set the path to nil.