api - in REST what method to use for the sync operation -


synchronizing data once user gets online involves both insert , update (upsert) , i'm sending both kinds of records in single request (array) , server iterates through records determine insert or update.

my question whether use post or put?

also how response server (json) should in it's body? data sent array, example

{   "ids" : "15,16,17",   "success" : true } 

edit:

and should response code, has both create , update operations:

200 ok 201 created 

rest not crud. mapping http methods crud operations convention introduced frameworks, has nothing rest. read this answer clarification on that.

a put complete replacement ignores current state of resource. think of mv command in shell. if there's nothing on destination, creates it. if there's something, replaces completely, ignoring whatever in there. that's how put should work. ideally, application should have uniform implementation of put works in exact same way uri supports method..

a post submits payload processed target resource under predefined rules. means can use post operation isn't standardized http protocol.

in case, it's not complete replacement, it's not case put. use post.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -