-1

I have written Post API that can accept Array of objects like [{"name":"ABC","city":"Banglo"},{"name":"AC","city":"Newyork"},{"name":"C","city":"Mumbai"}] in Java using the Dropwizard framework.

Now I'm trying to call these API method through Backbone Collection create function.Ist i knew that create accept only one object at time like collection.create({"name":"ABC","city":"Banglore"}).Suppose if I passed array of objects in create then it parsed as {"0":{"name":"ABC","city":"Banglor"},"1":{"name":"AC","city":"Newyork"},"2":{"name":"C","city":"Mumbai"}}. But Java API could not accept key value pair objects.So How can i call those API method from backbone collection.

Jeff Sloyer
  • 4,899
  • 1
  • 24
  • 48
Amit Sah
  • 41
  • 3

1 Answers1

0

You are correct, create accepts properties for a single model. You may want to just use add instead, which accepts an array of models or objects containing properties (if a model property is defined in the collection). Then, call the sync method to add pass those to your API.