For all the good intentions in including a REST server natively in Drupal 8, many aspects of it come across as incomplete and rushed. The most noticeable is in the differences between the URIs used to request resources. One of the hallmarks of a good REST interface is consistency, that there are essentially only two URIs and four actions. For example:
- To retrieve a list of users you would make a GET request to /user
- To create a new user you would make a POST request to /user
- To retrieve information about a specific user with an ID of 1 you would make a GET request to /user/1
- To update that user you would make a PUT or PATCH request to /user/1
- To delete that user you would make a DELETE request to /user/1
Unfortunately, in Drupal, you have /user/1 for GET, PATCH and DELETE, but then /entity/user for POST, and the URI to list resources needs to be created by the user, and has to be on a separate URI. There are further issues with the authentication methods that are available in core: inconsistent use of HAL and issues with content negotiation and serialization that require knowledge of a large number of idiosyncrasies. We'll discuss these other issues in more detail in other sections in this chapter.