Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
This page describes the nodes
endpoint, which can be used to access and manipulate JCR nodes.
GET
Returns a node from the specified workspace and path.
Request URL
/.rest/nodes/v1/{workspace}/{path}
Parameters
Parameter | Description | Parameter type | Data type |
| required The name of the workspace. |
|
|
| optional, default is The absolute path to the node within the workspace. |
|
|
| optional, default is The depth of child nodes to be included. |
|
|
| optional A list of node types to be excluded. |
|
|
| optional, default is If set to |
|
|
Example
Read the content of the /travel/about/company
node from the website
workspace including the metadata.
curl -X GET 'http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/website/travel/about/company?includeMetadata=true' \ -u superuser:superuser
curl -X GET 'http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/website/travel/about/company?includeMetadata=true' \ -u superuser:superuser -H "Accept: application/xml"
PUT
Creates a new node and adds the properties passed in the request.
You can add only one node per request. You cannot PUT nested nodes.
Request URL
/.rest/nodes/v1/{workspace}/{path}
Parameters
Parameter | Description | Parameter type | Data type |
| required The name of the workspace to add a node to. |
|
|
| optional, default is The absolute parent path of the new node. |
|
|
| required Request body format: JSON (default) or XML. |
|
|
Example 1
Create a new page called /travel/hello
(add a new node to the website
workspace).
curl http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/website/travel \ -H "Content-Type: application/json" \ -X PUT -i \ --user superuser:superuser \ --data \ '{ "name": "hello", "type": "mgnl:page", "path": "/travel/hello", "properties": [ { "name": "title", "type": "String", "multiple": false, "values": [ "Hello REST" ] }, { "name": "mgnl:template", "type": "String", "multiple": false, "values": [ "travel-demo:pages/standard" ] } ] }'
curl http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/website/travel \ -H "Content-Type: application/xml" \ -X PUT -i \ --user superuser:superuser \ --data \ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <node> <name>hello</name> <path>/travel/hello</path> <properties> <property> <multiple>false</multiple> <name>mgnl:template</name> <type>String</type> <values> <value>travel-demo:pages/standard</value> </values> </property> <property> <multiple>false</multiple> <name>title</name> <type>String</type> <values> <value>Hello REST</value> </values> </property> </properties> <type>mgnl:page</type> </node>'
Tip: Use the
-i
option with cURL to show the HTTP response headers.
Example 2
Create a tour called /magnolia-travels/rest-tour
indicating the date in which it takes place.
The Date is assumed to be in the GMT time zone.
curl http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/tours/magnolia-travels \ -H "Content-Type: application/json" \ -X PUT -i \ --user superuser:superuser \ --data \ '{ "name": "rest-tour", "type": "mgnl:content", "path": "/magnolia-travels/rest-tour", "properties": [ { "name": "author", "type": "String", "multiple": false, "values": [ "Magnolia Travels" ] } , { "name":"date", "type":"Date", "multiple":false, "values":["2020-05-01T12:11:25"]} , { "name": "body", "type": "String", "multiple": false, "values": [ "This a tour created through the nodes endpoint" ] }, { "name": "description", "type": "String", "multiple": false, "values": [ "Description of the tour created through the nodes endpoint" ] }, { "name": "location", "type": "String", "multiple": false, "values": [ "Madrid, Spain" ] }, { "name": "name", "type": "String", "multiple": false, "values": [ "Tour created through nodes endpoint" ] } ] }'
POST
Updates a node by adding the properties passed in the request. The method is changing only the properties passed with the response body. Other existing properties and subnodes are not affected.
Request URL
/.rest/nodes/v1/{workspace}/{path}
Parameters
Parameter | Description | Parameter type | Data type |
| required The name of the workspace. |
|
|
| optional, default is The path of the node to be updated. |
|
|
| required Request body format: JSON or XML. |
|
|
Example
Update the title
and hideInNav
properties of the /travel/hello
page.
curl http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/website/travel/hello \ -H "Content-Type: application/json" \ -X POST -i \ --user superuser:superuser \ --data \ '{ "properties": [ { "name": "title", "type": "String", "values": [ "Hello REST updated" ] }, { "name": "hideInNav", "type": "Boolean", "values": [ true ] } ] }'
curl http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/website/travel/hello \ -H "Content-Type: application/xml" \ -X POST -i \ --user superuser:superuser \ --data \ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <node> <properties> <property> <multiple>false</multiple> <name>title</name> <type>String</type> <values> <value>Hello REST - updated with XML :-P</value> </values> </property> <property> <multiple>false</multiple> <name>hideInNav</name> <type>Boolean</type> <values> <value>true</value> </values> </property> </properties> </node>'
DELETE
Deletes a node.
Request URL
/.rest/nodes/v1/{workspace}/{path}
Parameters
Parameter | Description | Parameter type | Data type |
| required The name of the workspace. |
|
|
| optional, default is The path of the node which you want to delete.
|
|
|
Example
Delete the /destinations/polar
node in the category
workspace:
curl -X DELETE 'http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/category/destinations/polar' \ -u superuser:superuser -i
The DELETE
method is shown here for the sake of completeness only. If the content has already been published, applying this method is not a good idea. In most of your cases you had better apply the chained command delete
with the commands
endpoint instead of directy deleting the nodes via the DELETE
method.