Reproduction:

  1. Install database search defaults
  2. Create rest export view based on default index, provide rest export
  3. Set format to facets serializer
  4. Save view
  5. Create a facet based on the rest export view
  6. Select array with raw results format
  7. Go to view url and see "client error"

From log:
Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException: No route found for the specified format html. in Drupal\Core\Routing\RequestFormatRouteFilter->filter() (line 51 of
/app/web/core/lib/Drupal/Core/Routing/RequestFormatRouteFilter.php).

This error is also thrown on the views listing page. Sometimes the view breaks and becomes ineditable.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mortona2k created an issue. See original summary.

borisson_’s picture

Category: Bug report » Support request
Issue summary: View changes

I think this is expected behavior now, you should add the format to your request: /search/rest?_format=json

borisson_’s picture

Status: Active » Postponed (maintainer needs more info)
mortona2k’s picture

I can get output with the format parameter. How do I set the facet value in the request?

The last line in my report says the views ui is broken. I literally can't access the list of views after creating one with a rest facet display. I also can't edit the view after saving it.

I really appreciate you getting back to me. I'd really like to get this working for a project, and am willing to put in time to debug and improve.

Maybe it's just something I'm doing wrong in the order of creating the view and facet, or some facet config mistake?

borisson_’s picture

Status: Postponed (maintainer needs more info) » Active

I can get output with the format parameter. How do I set the facet value in the request?

The facets that are passed out from the output, should contain a link to filter by them.

The last line in my report says the views ui is broken. I literally can't access the list of views after creating one with a rest facet display. I also can't edit the view after saving it.

That is really weird, I can't reproduce this behavior at all. Can you reproduce this on a clean drupal install?

mortona2k’s picture

I'm trying this on a fresh drupal install after a composer update.

I installed search_api_db_defaults, realistic_dummy_content, and facets_rest. Then created some dummy content.

This time, I created the rest export view and saved it, then created the facet. Everything was ok at this point.

Then I changed the view plugin to facets serializer and saved, that's when the view and view listing breaks and says "A client error happened."

Here's my view config:
view config

mortona2k’s picture

Here's a simplytest site that's set up as I described (without the dummy content):
https://dps6.ply.st/admin/structure/views/view/rest_facets/edit/rest_exp...

Login is admin:admin.

If you click on the second view display configured with facets serializer, it will crash. Also if you go to the views list.

To undo the broken display, delete it here:
https://dps6.ply.st/admin/structure/views/nojs/reorder-displays/rest_fac...

Maybe there's just some obvious config error I'm making, I'd really appreciate it if you could show me a basic setup that works in that site.

drasgardian’s picture

Status: Active » Needs review
FileSize
1.1 KB

The attached patch cleared this error up for me.

removing the defineOptions() function fixed the "client error" errors, and allowed the requested formats (csv, json, xml) views config to be saved.

The second part of the patch got the views results correctly formatted.

-    return $this->serializer->serialize($rows, $content_type, ['views_style_plugin' => $this]);
+    return $this->serializer->serialize($rows['search_results'], $content_type, ['views_style_plugin' => $this]);

Status: Needs review » Needs work

The last submitted patch, 8: facets-rest_view_broken-2939871-8-D8.patch, failed testing. View results

borisson_’s picture

-    return $this->serializer->serialize($rows, $content_type, ['views_style_plugin' => $this]);
+    return $this->serializer->serialize($rows['search_results'], $content_type, ['views_style_plugin' => $this]);

Wait, huh? How is this supposed to still return the facets? Does this not remove the facets from the rest output?

The tests seem to agree with that.

drasgardian’s picture

Sorry, maybe I misunderstood what the expected output is here. I was aiming for a csv output respecting the same facet filters as my page display, which worked quite well.

borisson_’s picture

@drasgardian: the expected output is to have the facets, as well as the search api results in the output. Your issue is an interesting one - that should be a new feature request.

borisson_’s picture

Sorry, maybe I misunderstood what the expected output is here. I was aiming for a csv output respecting the same facet filters as my page display, which worked quite well.

That sounds like a really good idea, I created #2956898: Add an option to the rest export to not show the facets in the export. to do that, I think that means we can close this issue, and remove the ::defineOptions when we actually add tests for csv and/or xml?

borisson_’s picture

Status: Needs work » Closed (duplicate)

I'm closing this, because it went in different directions, and there is a patch that resolves the problem in #11 in #2956898: Add an option to the rest export to not show the facets in the export..