We have an
orderShare resource whose attributes include an order number and a customer number. Both must be specified in the POST request to create the resource. However, there can only exist one
orderShare per unique order number and customer number combo.
Currently I return an error if someone attempts to create an
orderShare for a customer number and order number when such a resource already exists.
An alternative solution is to return the existing resource. I’m not sure whether that violates the spec (formally or in spirit). For example, it seems weird to return
201 Created and a
Location header when returning an existing resource. Another complication is that the
POST request can specify other fields which do not match the existing resource - one must decide whether they should be set to the requested values or kept as-is.
Any opinions on this?