This would seem to be a pretty basic question, but I can't seem to find appropraite guidelines for it. What is the "restful" way of
POSTing a relationship between two entities that are not necessarily parent/child. As an example, consider customers and orders.
One could create a customer with a
/customer. However, what is the best way to create the order? One example would be a
/customer/123/order, but what if the order isn't assigned to a customer directly, and could exist on its own (in the case of a web-cart that allows for "anonymous" checkout)? Is the right way, then, to do
Further, consider the case that an order can be submitted separately from payments (let's say we are invoicing a customer). You could create the order (per either of the methods above), but how would we make the payment?
POST /order/123/payment or
POST /payment?orderId=123 (if we assume that a payment can be made for something other than an order, and one might want to get information about an order/payment without knowing the specific customer).