0
我正在设计一个新的REST API端点并对API url有疑问。REST服务资源命名
例如,我有一个Product
实体和相应的/products
API。
,以获得特定的产品,一切都清楚了 - 我必须使用类似于:
GET /products/{productId}
,以创建一个新的一切都太清晰:
POST /products with a product details in the HTTP request body
但如何处理产品更新?
有两个选择,我可以看到现在:
PUT /products/{productId} with a new product details in the HTTP request body
或
PUT /products with a {productId} and new product details in the HTTP request body
同样的问题产品中删除。
为了将{productId}
发送到服务器,这里的最佳实践是什么?