Follow these steps to expose resources to GET requests:
First make sure that REST module is enabled.
You may skip the steps below as by default all operations on entity:node are enabled. Below are the steps needed if you want to fine-tune your settings.
- Copy all of the files in your active config directory to your staging directory
- Make the needed changes to your rest.settings.yml file as shown below
- Go to admin/config/development/configuration to sync the configuration
- Clear caches
# Example configuration for enabling REST resources.
# Enable the node resource.
# Enable the taxonomy term resource.
Go to /admin/people/permissions#module-rest and grant the corresponding REST permission to a user role you would like to be able to access the resource. Note: entity and field access still applies on top of that.
This can also be done with drush:
drush role-add-perm anonymous 'restful get entity:node'
Test with a GET request
You can use many clients to test requests.
// Example using basic auth.
$response = \Drupal::httpClient()
'auth' => ['username', 'password'], // Only required with basic auth.
$json_string = (string) $response->getBody();
Dev HTTP Client
An easy way to test is using a browser extension such as Dev HTTP Client. This exposes options for all of the HTTP headers that you may need to use.
UPDATE: Url has changed from 'mysite.com/entity/node/1' to 'mysite.com/node/1?_format=hal_json' see - http://dgo.to/2501221