W
W
WebDev2020-10-15 11:24:57
RESTful API
WebDev, 2020-10-15 11:24:57

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

1 answer(s)
P
Pavel Shvedov, 2020-10-15
@mmmaaak

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 question

Ask a Question

731 491 924 answers to any question