0

How can I post an array of objects to my server with RESTKit?

I have a custom object called Contact which have some properties like name, phone etc. I would like to send an array of these Contact objects to the server. The method I know for this is postObject:path:parameters:success:failure, but what object I put here? If I put Contact - how will it know it is an array? and if I put NSArray, how will it know it is a Contact?

bobsacameno
  • 765
  • 3
  • 10
  • 25
  • I haven't used RESTKit, but, have you tried the two approaches that you've mentioned? Let it figure out what the object is, if it can't it will at-least hint you about what it needs in form of an Exception – bhargavg Aug 11 '14 at 12:19
  • Have you already tried something like: NSDictionary *parameters = @{"ContactKey":@[contact1,contact2]} and then use that dictionary for posting objects? – razor28 Aug 11 '14 at 12:42
  • Please update your existing question instead of asking a new copy of the same thing. – Wain Aug 11 '14 at 12:47
  • @Wain I wasn't sure if it's the same question, since the first one was about the **ability** of RESTKit to send a **large** array, and this was about **how** to send an array. But I've updated the [former question](http://stackoverflow.com/questions/25228098/restkit-post-a-large-array-of-objects-to-server) anyway. – bobsacameno Aug 11 '14 at 12:54
  • @razor28 I have tried your suggestion, but it didn't work with RESTKit. The error I get is : `Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot merge parameters with array of object representations serialized with a nil root key path.'` – bobsacameno Aug 13 '14 at 17:34

0 Answers0