I'm wondering which is the best choice for the HTTP response code in the following situation:
There is a POST / PUT REST API that associates a resource (let's call it source item) with another one (let's call it destination item), using a 1-1 requirement (one-to-one).
If the source item is already associated with another resource, the API should return an error. If the source item is not already associated with any resource, but the destination one is, the API should succeed instead by replacing the current association of the destination.
I'm going with 409 Conflict, but since it indicates a conflict in the target resource, I'm not sure if it is the most appropriate.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409