Avoid duplicate POSTs with REST -


i have been using post in rest api create objects. every once in while, server create object, client disconnected before receives 201 created response. client sees failed post request, , tries again later, , server happily creates duplicate object...

others must have had problem, right? google around, , seems ignore it.

i have 2 solutions:

a) use put instead, , create (gu)id on client.

b) add guid objects created on client, , have server enforce unique-ness.

a doesn't match existing frameworks well, , b feels hack. how other people solve this, in real world?

edit:

with backbone.js, can set guid id when create object on client. when saved, backbone put request. make rest backend handle put non-existing id's, , you're set.

i use b -- detection of dups due whatever problem belongs on server side.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -