October 2018
Intermediate to advanced
590 pages
15h 5m
English
Before we discuss it any further, let's see a popular example of the usage of HATEAOS, which is to buy a cup of coffee via a RESTful API, like the following:
POST https://api.examplebucks.org/orders HTTP/1.1Content-Type: application/jsonContent-Length: 33{"drink": "latte", "quantity": 1}
This is a POST request, which has been sent to order a cup of latte. In its response, the server provides information about what the client can do next, as shown in the following code:
{ "id": 12345, "drink": "latte", "quantity": 1, "cost": "5", "status": "pending", "_links": { "self": { "href": "https://api.examplebucks.org/orders/12345", "type": "GET" }, "payment": { "href": "https://api.examplebucks.org/payments/12345", "type": "PUT"Read now
Unlock full access