So here is what the method looks like now:
POST person/personId/edit
https://api.example.com/*key*/person/*personId*/edit?FName=Blah
I want this to change the first name of person at personId to Blah.
And if I need to add a person I say:
PUT person/create
https://api.example.com/*key*/person/create
and it will add a person with a new personId.
My interpretation of POST and PUT has always been:
POST - The server will receive an entity which it can use to perform an operation or create a resource. If the endpoint's intent is to create a resource, then POST will always create a NEW resource. In any case, each POST will be treated without regards to the state of a resource. You are simply posting information to the server for it to operate on.
Example:
PUT - The server will receive an entity (with an ID, for example) with the intent of creating or replacing a resource. If the resource already exists, it will be replaced with the one within the request, otherwise a new resource will be created. In all cases, something is persisted on the server. Some way to uniquely identify the entity must be provided. In other words, the client is the one that creates the ID because it will be used if entity needs to be created. Most people I know struggle with this reality.
Example:
The general convention is usually:
GET => READ
POST => CREATE
DELETE => DELETE
PUT => UPDATE
A difference I can see is that you are also using different URIs, what is most commonly use is a single resource URI. But, anyways that's debatable so it is a matter of how you like it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.