JavaScript and REST

This page aims to outline how to use JavaScript to communicate with Drupal 8's RESTful services. It is broken into sections per entity type. It outlines which HTTP method to use (GET, POST, PATCH, or DELETE), the Drupal path to use, which Content-type and Accept headers should be set, and what response can be expected from the server.

We can use cookie based authentication. Any calls using POST, PATCH or DELETE need an X-CSRF-Token header attached to the request, using a token value that can be retrieved via the Drupal site at: rest/session/token

Using a different field for URL ID

In some cases you may wish to use something other than the Drupal entity IDs as the IDs in your API URLs (if, for example, you wish to use some sort of FQN, UUID, or similar for an API that needs to be integrated with other systems that are not aware of the Drupal ID system and have other constraints on IDs).

This can be easily done with restful, though it does take implementing the correct API methods.

By default, restful supports only numeric IDs in URLs. To change this, implement getControllers in your plugin class:

Recipes for RESTful

These are some recipes for common tasks for the RESTful module.

RESTful best practices for Drupal

The RESTful module achieves a practical RESTful for Drupal following best practices.

Concept

The following also describes the difference between other modules such as RestWs and Services Entity.

Comparison of Web-service client modules

There are several modules in Drupal that act as Web-service clients. Ideally, we'd only have one, but this page attempts to point them out and highlight some differences. At some point, perhaps for Drupal 8, we'll be able to merge all of these.

Services Security Updates

This page is used as documentation for Services Security. Its unfortunate that issues come up that affect Services but running the latest version of Services should help mitigate issues.

If you see an issue and think it is security related please follow the instructions here

Pages

Subscribe with RSS Subscribe to RSS - rest