HTTP and RESTFUL services Flashcards
POST
POST
you use POST to creat a resource and instruct the server to make a uniform resource identifier (URI) for it. For example, when you want to create anew article you would POST to /articles to make the file and get the URI, so you end up with /articles/1234/.
PUT
PUT
PUT also creates resources, but it does so for a known URI. So, you can PUT to /articles/1234/. If the article doesn’t exist, PUT creates it. If it does exist, this HTTP verb updates it. While PUT seems nearly identical to POST, the difference between the two comes donw to idempotence.
Idempotence is a property that creates identical side effects whether you have one or many results. PUT has this characteristic, while POST creates new resources infinitely. In general, POST works best for resource creation, while PUT handles updates.
PATCH
PATCH
This HTTP verb partially updates resources without sending the complete representation of it. When you’re working with complicated objects and resources, it’s a big deal to update more than you need to.
example:
{ “first_name”: “Claude”, “last_name”: “Elements”, “email”: “claude@cloud-elements.com”, “favorite_color”: “blue” }
PATCH allows you to change the color with: JSON :{ “favorite_color”: “purple” }.
GET
The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
DELETE
The DELETE method deletes the specified resource.