Consequences of POST not being idempotent (RESTful API)

前端 未结 6 1478
傲寒
傲寒 2021-01-30 09:13

I am wondering if my current approach makes sense or if there is a better way to do it.

I have multiple situations where i want to create new objects and let the server

6条回答
  •  深忆病人
    2021-01-30 09:58

    The only advantage of POST-creation over PUT-creation is the server generation of IDs. I don't think it worths the lack of idempotency (and then the need for removing duplicates or empty objets).

    Instead, I would use a PUT with a UUID in the URL. Owing to UUID generators you are nearly sure that the ID you generate client-side will be unique server-side.

提交回复
热议问题