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.
- 1. Go to admin/modules and enable the required modules available in the core (REST and Serialization).
- 2. Next, For testing purposes, you can create dummy content using the existing content types. (Articles or Basic page)
- 3. Now, create a view using the available content. We don't need to select a page or block while creating views.
- 4. 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.
- 5. Specify a path for REST export which will be used to return formatted contents of the created view display.
- 6. 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.