-
As an administrative user of a Drupal 8 site you can set up a site wide API key.
-
As Anonymous/Authenticated user you can access
page
content in JSON format on your site if you have the following :- Site API Key
- Node ID of the content.
-
Enable the module via drush
drush en -y siteapi
, -
Login in as a administrator,
-
Goto
/admin/config/system/site-information
-
Enter the Site API key for Eg :
FOOBAR12345
and Save the Form. -
Make sure you have
page
type content on your site. -
Go to the link of the format
http(s)://<sitename>/page_json/<SITEAPIKEY>/<NODE_ID>
<SITEAPIKEY>
key which you entered and saved in step 4,<NODE_ID>
- The Unique node id of the content you want to Access. Note : The content should be of typePage
Eg :
http://localhost/page_json/FOOBAR12345/17
- Correct API Key, Node ID of a
Page
content.
{ "Node ID": "1", "title": "Sample Test Page", "Contents": [ { "value": "<p> Sample Body. Lorem ipsum </p>" "summary": "", "format": "basic_html" } ], "Node Type": "page", "Node Access": "Granted" }
-
Incorrect API key .
[ "Access Denied", "Reason : API Key Invalid" ]
-
Non-numeric NODE_ID.
[ "Access Denied", "Reason : Invalid Node ID. Please enter numeric Node ID value only" ]
-
NODE_ID of a Node which does not exist or not of type
page
.[ "Access Denied", "Reason : Node does not exist or not of type page" ]
Overall Coding Time - 2 Hours
Coffee Intake - 1 Mug :)