[PP-1] Since 8.5.0, getUrlIfValid('/path/to/rest') will throw an exception if there is no route found for html; how to get a valid Url for a Json path?

Created on 13 March 2018, over 6 years ago
Updated 24 February 2023, over 1 year ago

I have a Rest path which I can call using /path/to/rest?_format=json.

Before #2449143: REST views specify HTML as a possible request format, so if there is a "regular" HTML view on the same path, it will serve JSON β†’ , I could use \Drupal::service('path.validator')->getUrlIfValid('/path/to/rest'). Now that throws an exception "No route found for the specified format html".

How can I get the Url object to /path/to/rest?

πŸ’¬ Support request
Status

Closed: duplicate

Version

8.5 ⚰️

Component
RESTΒ  β†’

Last updated about 1 month ago

Created by

πŸ‡¨πŸ‡¦Canada alberto56

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024