How to configure views REST export in Drupal 8

  • By : Prince
  • Date :10-04-2018

As all know, Drupal 8 is API driven first and keeps on adding in new API's which can be altered, extended for different decoupled Applications. When we talk about decoupled Drupal, developers are allowed to use any technology frontend to bring in better User experiences. The actual UI experience is met when we present contents which fulfill the needs and requirements of the user.

Drupal 8 Views

Drupal 8 views are now in the core and are among the greatest features available with Drupal to handle any type of dynamic UI designs to bring in better user experiences. Using RESTful views, we can embed views content to external applications.

In this guide, you will learn how to get the view content in JSON or XML format via Rest API.

  • Step1. Go to admin/modules and enable the required modules available in the core (REST and Serialization).
  • Step2. Next, For testing purposes, you can create dummy content using the existing content types. (Articles or Basic page)
  • Step3. Now, create a view using the available content. We don't need to select a page or block while creating views.
  • Step4. After you have created a view with the required fields, we need to select REST export display from the Add options right of Master display in the views.

Drupal 8 Views

  • Step5. Specify a path for REST export which will be used to return formatted contents of the created view display.
  • Step6. You will also find an option to select the required format (say JSON, XML etc.) that will be allowed in the responses.

That's it, you have the Request URL to return either entities or fields from views. When you try accessing the URL directly on the browser, you will have view exported with the format you have selected or JSON by default. Also, you can test the formatted data using POSTMAN services available with Google Chrome.

Hope, the above steps will help you built REST API using Drupal views. Get in touch with our Drupal developers if you face any queries working with API's. We will be glad to help.

Tell us your requirements

CONTACT US

Recent blogs

Web Accessibility With Drupal 8
Generally, people refer web accessibility with screen readers or visual disabilities. However, the range of topics that it covers...
Android Tutorials
In this tutorial, we will be discussing about building an android application for creating a possible route map between two points.
Return on Investment
Businesses and enterprise organisations today are falling into a trap. A trap built around the ROI of their business. Return on...