O'Reilly logo

Drupal 8: Enterprise Web Development by Chaz Chumley, Matt Glaman, Richard Jones, Nick Abbott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using POST to create data

When working with RESTful Web Services, the HTTP POST method is used to create new entities. We will use the Basic HTTP Authentication to authenticate a user and create a new 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 POST 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 also need to install the HTTP Basic Authentication ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required