Using PATCH to update data

When working with RESTful Web Services, the HTTP PATCH method is used to update entities. We will use the Basic HTTP Authentication to authenticate a user and update a node.

In this recipe, we will use the exposed node endpoint to create a new piece of article content through the RESTful Web Services module. It is a requirement to use HAL JSON when making PATCH requests, which is provided as the default format for the node endpoint.

Getting ready

We will be using the Article content type provided by the standard installation.

How to do it…

  1. Visit Extend from the administrative toolbar and install the Web Services modules: Serialization, RESTful Web Services, and HAL
  2. We need to also install the HTTP Basic Authentication module. ...

Get Drupal 8: Enterprise Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.