1

I'm using Drupal 9, JSON:API module, Domain access module.

My task is to throw a custom exception when the request doesn't contain a specific parameter (domain-entity in my case).

For example - test-website.com/domain-parameter/jsonapi/some-entity

I need to throw a text "Please, specify domain-parameter to get correct data" if the domain-parameter is not specified in the URL above.

I've read a lot of articles about handling JSON API requests/altering JSON-API responses etc., but nothing helped me. I've found information that it's possible to achieve by writing a custom EventsSubscriber, but I'm not sure whether it's the best option.

Appreciate any help.

Yaroslav
  • 11
  • 2

0 Answers0