I’m trying to POST an object using Restkit, but when I set some extra parameters, it doesn’t post the object anymore.
NSDictionary *params = [NSDictionary dictionaryWithObject:@"mic" forKey:@"type"];
[[RKObjectManager sharedManager] sendObject:rating toResourcePath:@"/mic" usingBlock:^(RKObjectLoader *loader) {
loader.delegate = self;
loader.method = RKRequestMethodPOST;
loader.params = params; // without this line, the 'rating' object is posted,
}];
I need to send extra POST parameters which isn’t included within the object, with the code above, I receive the extra “type” parameter via POST, but the object isn’t received.
I read the Parameters section of the documentation https://github.com/RestKit/RestKit/wiki/Object-mapping – the documentation must be a bit old as the method has changed, but the concept is the same. I don’t see what i’m doing wrong…help is much appreciated.
I found the solution, it’s a bit long winded because when using
sendObjectandloadObjectunfortunately the method assumes you will get back the same object in return as the one you’re sending. This isn’t the case for me as it will either return the same object…or an error object. So this is how I done itI serialised the object within the block, then added a parameter to the the resulting dictionary. That way, I don’t have to give the object an extra “type” property…it would mean I would have to add that to every object I plan on posting.