GET on Views-generated lists

Last updated on
11 March 2021

This documentation needs work. See "Help improve this page" in the sidebar.

The REST export display plugin uses the Serializer to output lists of entities in different formats (JSON, XML, ...).

NOTE: The REST export plugin does not use the REST resource plugin. The permissions defined by REST do not apply to Views.

Setup

  1. Ensure that the REST and Serialization modules are enabled.
  2. Create a view and add a REST export display. Make sure to add a path to the display. You'll be using this path to access the JSON/XML data.

    REST export display configuration screen

  3. Enable data formats (JSON, XML, ...) in the Serializer format settings.

    Setting the enabled formats

Access

To view the Rest Export the query parameter _format must be included in the url, and contain a valid request format. 

/content/rest?_format=json

Pager (Pagination)

There is limited support for pagination.  Only two of the four pager types have more than 1 page.  'Display all items' and 'Display a specific number of items' are a single page.  The Mini and Full pagers can be controlled by GET query parameter page and if is exposed to the user items_per_page. The response only includes the rows.  It does not include the total number of items, nor anything else to do with paging. 

[
  {...},
  {...}
]

The Pager Serialzer module extends the Serializer to include the pager by creating a custom Views style plugin. By default, the Pager Serializer module produces something like this, but allows for the keys to customized.

{
  rows: [
    {...},
    {...}
  ],
  pager: {
    current_page: 0,
    total_items: 6,
    total_pages: 2,
    items_per_page: 5
  }
}

Help improve this page

Page status: Needs work

You can: