Skip to main content

For an introduction into setting up RESTful hal+json refer to the set-up documentation.

GET a node

To get the content of the specific node you require the node.nid.  The key information required in the GET query:

  • URL - your-site.com/node/<nid>?_format=hal_json;
  • Content-Type - application/hal+json;
  • Nod.nid - noted in the URL string as <nid>.

Example using a node.nid of one (1).  So the nid in the URL is <nid> = 1

your-site.com/node/1?_format=hal_json

This get on the staging site will output the following: 

{
  "nid":[{"value":"1"}],
  "uuid":[{"value":"c5ab1e63-0b72-4325-bfe6-5c77d3a7acd4"}],
  "vid":[{"value":"1"}],
  "langcode":[{"value":"en"}],
  "type":[{"target_id":"page","target_type":"node_type","target_uuid":"078109da-c606-4810-b684-d3c059eb3aab"}],
  "title":[{"value":"Posting to your site using REST API"}],
  "uid":[{"target_id":"2","target_type":"user","target_uuid":"f000c9a3-82b2-4ef7-92bb-786f00863c66","url":"\/user\/2"}],
  "status":[{"value":"1"}],
  "created":[{"value":"1467305369"}],
  "changed":[{"value":"1467305390"}],
  "promote":[{"value":"0"}],
  "sticky":[{"value":"0"}],
  "revision_timestamp":[{"value":"1467305390"}],
  "revision_uid":[{"target_id":"2","target_type":"user","target_uuid":"f000c9a3-82b2-4ef7-92bb-786f00863c66","url":"\/user\/2"}],
  "revision_log":[],
  "revision_translation_affected":[{"value":"1"}],
  "default_langcode":[{"value":"1"}],
  "path":[],
  "body":[{"value":"<p>Lear how to POST via REST to Drupal your site.<\/p>\r\n","format":"basic_html","summary":""}]
}

 

Testing through Chrome

Using the Chrome extension DHC, enter the parameters noted above as a means of cross checking and testing.

Related articles

Andrew Fletcher04 Apr 2025
Managing .gitignore changes
When working with Git, the .gitignore file plays a critical role in controlling which files and folders are tracked by version control. Yet, many developers are unsure when changes to .gitignore take effect and how to manage files that are already being tracked. This uncertainty can lead to...
Andrew Fletcher26 Mar 2025
How to fix the ‘Undefined function t’ error in Drupal 10 or 11 code
Upgrading to Drupal 10.4+ you might have noticed a warning in their code editor stating “Undefined function ‘t’”. While Drupal’s `t()` function remains valid in procedural code, some language analysis tools — such as Intelephense — do not automatically recognise Drupal’s global functions. This...
Andrew Fletcher17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...