rest - Which way should I create a list of objects when sending POST request -


when creating same type objects , save them database, should send list of objects in 1 request or should send individually each one?

for example, create todo list, can create multiple todos, click save send list of todos, or when finish editing 1 todo, save directly.

the first way can save request numbers, 1 request needed create many objects. first way restful? infomation create in rest creating single object, there poblems if increasing requests numbers?

----edit

thank guys answering me.

for more spicific usecase, using django rest framework. created todo model , corresponding serializer. wondering, how create list of todos? tried send list of todos serializer, , expecting serializer can automatically loop through same getting list of instance. doesn't work. know may able create loop call create method everytime. there better way it?

there nothing in rest tells kind of payload allowed use. can post/put whatever want - 1 entity representation or many representations, in lists, dictionaries, xml, url-encoded key/values or json, ever suits use case best.

in case might want send delta/diff list of changes on client: lets instance client loads existing 3 todo items. user modifies 1 of them, deletes 1 , adds new one. can either in 3 requests or 1 single request add/modify/delete operations encoded in it. both ways valid , best solution depends on use case , constraints bandwidth, processing power , network round-trip time.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -