REST Flashcards
HTTP
GET
Use: to read data from resource
Read-only
Safe operation - does not change the state of the resource
HTTP
PUT
Use:
If not found, INSERT
if found, UPDATE
Multiple PUTs will not change the result
Likely saving a file multiple times
Not Safe operation - DOES change the state of the resource
HTTP
POST
Use: To CREATE a new object (inset)
Multiple POSTs is expected to create multiple objects
Not Safe Operation - does change the state of the resource
HTTP
DELETE
Use: To delete an object (resource)
Multiple DELETEs will have the same effect/behavior
Not Safe Operator: Does change the state of the resource
What do you mean by Safe Methods?
Because they only fetch information, do not cause changes to the server
GET
HEAD
OPTIONS
TRACE
HTTP
PATCH
Partial modification to the specified resources
Not Safe Operator:
Idempotence
Action such as repetition that have no further effect on the outcome
Example:
PUT - If you found it you update it
DELETE - you can’t delete twice
Is POST Idempotent?
No
POST is likely to create multiple objects.
When you post a form online and if refresh, they ask you if you want to repost it again.
Or when you are checking out and are asked not to refresh the page. (To avoid sending another post)