5. DELETE for deleting content entities

Follow these steps to expose resources to DELETE requests:

  1. Configuration
  2. Test with a DELETE request

Configuration

This builds upon the GET, POST and PATCH examples of the previous pages.

See Getting started: REST configuration & REST request fundamentals — Configuration

Sample requests below assume this configuration:

4. PATCH for updating content entities

Follow these steps to expose resources to PATCH requests:

  1. Configuration
  2. Test with a PATCH request

Configuration

This builds upon the GET and POST examples of the previous pages.

See Getting started: REST configuration & REST request fundamentals — Configuration

Sample requests below assume this configuration:

RESTful Web Services API

The RESTful Web Services API is new in Drupal 8.

For each REST resource, you can specify the supported verbs, and for each verb, you can specify the serialization formats & authentication mechanisms.

API features

Ordered by most to least frequently used APIs:

Entity Pilot - content staging for Drupal 8

Installation

  • Download and extract the module
  • Add the php-encryption library using composer or Composer manager.
    • For composer - from your Drupal installation directory run composer require "defuse/php-encryption:~1.2.
    • For Composer manager, refer to its documentation

Getting started

OAuth patch example

Here is a practical example on how to update a node.

Let's suppose that we have a node with id 56 whose title we want to update through a PATCH request, authenticating the request with OAuth.

Setting up REST

We need to enable the PATCH method with HAL format and OAuth authentication. This can be done easily using REST UI module.

JavaScript and Drupal 8 RESTful Web Services

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:

  1. which HTTP method to use (GET, POST, PATCH, or DELETE) on which URL
  2. which headers to send
  3. what response can be expected from the server

For the following entity types:

Pages

Subscribe with RSS Subscribe to RSS - rest