-2
Not only this site, but several others use the example of creating a user on a website:
www.site.com.br/user/id_do_usuario
To clarify that PUT would only update the old user with the entered data, and POST would create a new one, when requesting an existing id. But how POST deals with creating a new user, if the URIS are the same?
And what would be the problem of being the same? In fact, there are numerous Apis that have a single URL for various operations. Who defines how she will behave is who wrote the API. Perhaps it would be interesting if you [Dit] the post and better base where you got the conclusion that the URI would determine the behavior of the API, or restrict its functionality in any way. Another example: I could have an API with the path
http://nomedosite/x
and do all operations with POST (delete user, create, edit, delete property, etc.) just changing the data sent.– Bacco
@Bacco for example, when creating a user profile based on the name defined by the client in an input field. I don’t understand how different users could have the same URI
– abcson
Remember that URL is opaque and does not necessarily reflect the logic of the application. If I want to have in my API the URL
/batatas
and use it to send an email to the US President in the GET method I could.– Woss
abcson precisely, and what induced you to think that one thing has relation to the other (the URI with the result)?
– Bacco