Using web protocols
In REST, we use the same verbs as we do in HTTP: GET
, PUT
, POST
, and DELETE
. In addition, the API returns standard web values to the client, for example, 404 (not found)
, 200 (success)
, 201 (created)
, and so on.
Each request from the client to the API will consist of an HTTP header, body, and meta-data. The client expresses which API is wanted by calling a URL, and passes needed data (e.g., the id value for the requested entity
either in the URL or, if passing too much data for a URL, in the body of the request. For example, here is a POST to add a car to the backend database. Don’t worry about the syntax for now; rather, take a look at the URL and the body of the request in Figure 3.1.
Figure 3.1 – Sending data for insertion
At the top of the figure, we see the URL (https://localhost:7025/Car). This is the “address” of the API. Notice that the last part of the URL is Car. This is the name of the controller...