On this page
GET for reading content entities
Last updated on
11 March 2023
Configuration
See Getting started: REST configuration & REST request fundamentals — Configuration
Sample requests below assume this configuration:
resources:
entity:node:
GET:
supported_formats:
- hal_json
supported_auth:
- basic_auth
- cookie
NOTE: latest versions of Drupal 8 (at time of writing 8.9.x) don't have hal_json format available just json. Thus you need to substitute json wherever you see hal_json below.
Test with a GET request
You can use many clients to test requests.
cURL
curl http://example.com/node/1?_format=hal_json
Guzzle
$response = \Drupal::httpClient()
->get('http://example.com/node/1?_format=hal_json', [
'auth' => ['username', 'password'],
]);
$json_string = (string) $response->getBody();
jQuery
jQuery.ajax({
url: 'http://example.com/node/1?_format=hal_json',
method: 'GET',
success: function (comment) {
console.log(comment);
}
});
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.
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion