The REST link produced by API v3 Explorer gives 'page not found' under Drupal 9
Overview
The REST link produced by API v3 Explorer gives 'page not found', i.e. it doesn't work.
Reproduction steps
- Click on Support -> Developer -> API Explorer v3
- Choose Contact and Get.
- The Curl string returned is this:
curl '<drupal URL>/libraries/civicrm/core/extern/rest.php?entity=Contact&action=get&json=%7B%22sequential%22%3A1%7D&api_key=FIXME_USER_KEY&key=FIXME_SITE_KEY'
- Fix the FIXME values and copy and paste the URL into a browser.
Current behaviour
What happens currently. Please provide error messages, screenshots or gifs (LICEcap, SilentCast) where appropriate.
Expected behaviour
What should happen. JSON list of contacts should appear.
Environment information
- Browser: MS Edge but probably irrelevant.
- CiviCRM: 5.37.2
- PHP: 7.4 but probably irrelevant.
- CMS: Drupal 9.1.8
- Database: MySQL 8.0.25 but probably irrelevant.
- Web Server: IIS but probably irrelevant.
Comments
I know that REST is being deprecated, but there does not seem to be a replacement available.
The reason for the issue is that rest.php lives here:
<drupal root>/vendor/civicrm/civicrm-core/extern
not here:
/
<drupal root>/web/libraries/civicrm/core
A solution is to create a symbolic link to the extern folder in the latter folder. Copying the folder might also work, but then it would not be automatically updated when CiviCRM is updated.
There is an issue with rest.php itself, but I shall raise that as a separate issue.