diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index a0ef1e7..a9ed46c 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -107,7 +107,7 @@ public static function create(ContainerInterface $container, array $configuratio */ public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) { parent::initDisplay($view, $display, $options); - + $request_content_type = $this->view->getRequest()->getRequestFormat(); // Only use the requested content type if it's not 'html'. If it is then // default to 'json' to aid debugging. diff --git a/core/modules/rest/src/Plugin/views/style/Serializer.php b/core/modules/rest/src/Plugin/views/style/Serializer.php index 128a5e8..ba3ca6f 100644 --- a/core/modules/rest/src/Plugin/views/style/Serializer.php +++ b/core/modules/rest/src/Plugin/views/style/Serializer.php @@ -127,9 +127,12 @@ public function render() { // Get the content type configured in the display or fallback to the // default. - $default_content_type = empty($this->view->live_preview) ? $this->displayHandler->getContentType() : 'json'; - $content_type = isset($this->options['formats'][$default_content_type]) ? $this->options['formats'][$default_content_type] : $default_content_type; - + if ((empty($this->view->live_preview))) { + $content_type = $this->displayHandler->getContentType(); + } + else { + $content_type = !empty($this->options['formats']) ? reset($this->options['formats']) : 'json'; + } return $this->serializer->serialize($rows, $content_type); }