Allow JSON format when "Accepted request formats" is not defined

Created on 22 April 2023, over 1 year ago

Problem/Motivation

If you create a View and select "Provide a REST export", define a path such as export.json, save and access the path in a browser, you get this error:

Client error

A client error happened

From the log:

Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException: No route found for the specified format html. Supported formats: json, xml. in Drupal\Core\Routing\RequestFormatRouteFilter->filter() (line 65 of /app/web/core/lib/Drupal/Core/Routing/RequestFormatRouteFilter.php).

in Views, under Format > Settings it says:

Accepted request formats
[ ] json
[ ] xml
Request formats that will be allowed in responses. If none are selected all formats will be allowed.

If you select json and save, you can now access the export.json as expected.

Steps to reproduce

The error

  1. Create a View selecting "Provide a REST export"
  2. Define a path such as export.json
  3. Save the View
  4. Access the path in a browser and see the "Client error - A client error happened" message

The workaround

  1. In the View, open Format > Settings
  2. Enable json and save
  3. Open export.json in the browser, and see the data as expected

Proposed resolution

Allow not defining a format, as the text says: "Request formats that will be allowed in responses. If none are selected all formats will be allowed."

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 15 hours ago

Created by

πŸ‡©πŸ‡°Denmark ressa Copenhagen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024