Again, the request body contains a resource representation. In other words, if the PUT is to a URI that contains the value of a non-existent resource ID. However, PUT can also be used to create a resource in the case where the resource ID is chosen by the client instead of by the server.
PUT is most-often utilized for **update** capabilities, PUT-ing to a known resource URI with the request body containing the newly-updated representation of the original resource. Additionally, GET (and HEAD) is idempotent, which means that making multiple identical requests ends up having the same result as a single request.ĭo not expose unsafe operations via GET-it should never modify any resources on the server. That is, they can be called without risk of data modification or corruption-calling it once has the same effect as calling it 10 times, or none at all. Therefore, when used this way, they are considered safe. In an error case, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).Īccording to the design of the HTTP specification, GET (along with HEAD) requests are used only to read data and not change it.
In the “happy” (or non-error) path, GET returns a representation in XML or JSON and an HTTP response code of 200 (OK).
The HTTP GET method is used to **read** (or retrieve) a representation of a resource. 404 (Not Found), if ID not found or invalid. 404 (Not Found), if ID not found or invalid.Ĥ05 (Method Not Allowed), unless you want to modify the collection itself.Ĥ05 (Method Not Allowed), unless you want to delete the whole collection-not often desirable.Ģ00 (OK). 404 (Not Found), if ID not found or invalid.Ĥ05 (Method Not Allowed), unless you want to update/replace every resource in the entire collection.Ģ00 (OK) or 204 (No Content). Use pagination, sorting and filtering to navigate big lists.Ģ00 (OK), single customer. Of those less-frequent methods, OPTIONS and HEAD are used more often than others.īelow is a table summarizing recommended return values of the primary HTTP methods in combination with the resource URIs: HTTP VerbĢ01 (Created), 'Location' header with link to /customers/ containing new ID.Ĥ04 (Not Found), 409 (Conflict) if resource already exists.Ģ00 (OK), list of customers. There are a number of other verbs, too, but are utilized less frequently. These correspond to create, read, update, and delete (or CRUD) operations, respectively. The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. The HTTP verbs comprise a major portion of our “uniform interface” constraint and provide us the action counterpart to the noun-based resource.