Answer the question
In order to leave comments, you need to log in
How to call url for rest service?
Good evening, just starting to deal with the rest. How to correctly call the URL for an action (add a product to a client, remove a product from a client, etc.).
There are two tables. customer and product. Tied up mani to mani. To edit customer data, PUT /users/user is used, the same for products. The question arose of how to correctly add the action url for adding a product by the client?
After all, if you use users/user/?action=addproduct, then this is no longer rest
Answer the question
In order to leave comments, you need to log in
If your client is a seller. Then:
GET /api/v1/{userId}/products
GET /api/v1/{userId}/product/{id}
POST /api/v1/{userId}/product
PATCH /api/v1/{userId)/product /{id}
DELETE /api/v1/{userId}/product/{id}
If it's a customer, it's a good idea to add the cart entity .
GET /api/v1/cart
POST /api/v1/cart/item
PATCH /api/v1/cart/item/{id}
DELETE /api/v1/cart/item/{id
} id is not needed.
Orders:
GET /api/v1/{userId}/orders
GET/api/v1/{userId}/order/{id}
POST /api/v1/{userId}/order
PATCH /api/v1/{userId)/order/{id}
DELETE /api/v1/{userId}/ order/{id}
Dissolving endpoints via action is a bad idea.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question