Hi, I'm Lin Clark

Video: Setting up REST Services in Drupal 8

With Drupal 8, you can provide REST services to interact with your site’s data, and you don’t have to rely on contrib modules to do it. This screencast is the first in a series demonstrating how to configure such services. In this one, I will show the basic configuration for running GET requests for nodes.

  1. Add a node. We will be requesting this node when testing GET requests.
  2. Enable the REST module.
  3. Grant permission to the anonymous user to GET nodes.
  4. Update the configuration file:
    1. Copy all files from sites/default/files/config_XXX/active to sites/default/files/config_XXX/staging.
    2. Edit the rest.settings.yml file in your staging directory. Replace hal_json with json and basic_auth with cookie.
    3. Go to admin/config/development/configuration and import the changes.
  5. Test the endpoint:
    1. Enable the Postman REST Client, available as an extension for multiple browsers, or enable another client of your choice.
    2. Enter the URL of the resource. Add ‘entity’ before the node’s path (e.g. entity/node/1).
    3. Add the Accept header, Accept: application/json.
    4. Run the request. You should get a JSON object in response.

Next: DELETE requests and Cookie Authentication

For more information, check out the documentation on REST module.