Reputation: 2089
I am learning REST api (in php) and I have a question about where I should be putting the ID for the resource I want to update.
Do I put it in the URI and patch to /users/23 with body of:
{
“name”: “John”
}
Or in the JSON body and patch to /users
{
“id”: 23,
“name”: “John”
}
Upvotes: 1
Views: 709
Reputation: 91
As per Google Developer API design guidelines, API's should be resource oriented. i.e. API path in itself should define all the relevant information about the resource path. Hence, putting the path in URI itself is the best practice
Upvotes: 1