Answer the question
In order to leave comments, you need to log in
What is the correct way to create routes for RESTful API?
I have client and action entities. The client takes action.
To create a client, the route is like this -
[POST] /clients
And how will you correctly designate the route for creating an action?
[POST] /actions/{client_id}
or
[POST] /clients/{client_id}/actions
or is it generally just /actions and pass the client's id to the body?
Answer the question
In order to leave comments, you need to log in
Usually, in the url, the ID should belong to the entity itself, for example, when requesting or deleting by ID, if this ID is a property of the entity when created, then you can pass it in the body of the post request
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question