Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
...
Positive | For instance Firefox displays JSON and XML in a very readable format. |
Negative | A browser provides only limited control to tailor a request without further add-ons. Requests are sent as |
Tips | If you want to test on REST resources via Upgrade the browser with add-ons to extend its possibilities to controll control the request. |
cURL
is a command line tool. It can be used on most of the well-known operating systems.
Download | https://curl.haxx.se/download.html |
Positive | Very flexible to tailor for tailoring the request (method, request headers, user credentials, etc.and so on). Response can be further processed. |
Negative | Not everybody likes command line tools. The response is not easy to read without further tooling. No out-of-the-box automatic URL encoding. |
Tips | On the first atempt attempt of a request, use the If the response body is fine and delivers JSON, pretty-print and colorize the response body with tools such as jq. |
...
If you have not installed magnolia-rest-tools
with , which provides the swagger Swagger UI tools, skip this section , or see above about how to enable the swagger tools above.
Positive | Seamless Seamlessly integrated into the Magnolia UAdmin. Comfortable to use form-based interface. |
Negative | The endpoints require specific annotations to make them appear on the swagger Swagger UI tools. Delivery endpoint is not annotated and will does not appear on the swagger Swagger tools. REST request is sent by the user which who logged into Magnolia; cumbersome it is difficult to test with different users. |
...
Go to Dev > REST Tools.
Multiexcerpt | ||
---|---|---|
| ||
When you open the the Magnolia REST Tools app, you should see something similar to this screen: The Swagger UI lists the bundled endpoints which already have Swagger annotations. These are the endpoints from from the |
Now click Click on one of the links - it will to open a submenu which that shows all supported operations provided by the endpoint.
Click List operations or Expand or Expand operations to get the detail forms details for the operations.
Here is an example for for the nodes
endpoint
Mgnl get |
---|
nodes
endpoint operation:Enter values at least for the mandatory parameters and click the button click Try it out!.
Swagger will show shows the response code, the response headers and the response body:
...
The Delivery delivery endpoint is the latest a REST API provided by Magnolia out-of-the-box. Use it for obtaining JCR data as JSON.
Besides In addition to defining security settings - , you must provide YAML-based configuration for the delivery endpoint - otherwise the endpoint can not so that it can serve JSON.
delivery
...
We will create a light module to provide For the YAML-based configuration of required for the delivery endpoint - let us create a light module.
Within the In your light-modules folder - , which is configured with the property magnolia.resources.dir
, see above - create the following structure:
Code Block |
---|
define-delivery-endpoint/ └── restEndpoints/ └── delivery-base-definition.yaml |
To You can use this code to start with - the file for the delivery-base-definition.yaml
can look like this file:
Code Pro | ||||||
---|---|---|---|---|---|---|
| ||||||
class: info.magnolia.rest.delivery.jcr.v1.JcrDeliveryEndpointDefinition params: website: depth: 2 nodeTypes: - mgnl:page - mgnl:area - mgnl:component childNodeTypes: - mgnl:area - mgnl:component rootPath: / includeSystemProperties: false |
To get all the details - please refer to You can find a full explanation on Delivery endpoint API - YAML configuration.
For the time being, you should know note the following thingspoints:
website
is the name of the so called "endpoint prefix" - in . In our case it is also the name of a JCR workspace. We will use the value of the endpoint prefix later on within in the REST request URL.With the given configuration provided above - , you are ready to send REST requests to your Magnolia instance.
Let us We will fetch the content of the page /travel/about
on the website workspace. Have a look at Delivery endpoint API - readNode - to to understand how to compose the URL. We need:
website
travel/about
...
Now add the "context" (the name of the webapp), the domain and the protocoll - protocol, and you get this these URLs:
The You can request the first URL, which goes to the public contextinstance, you can request with the browser as the anonymous user (without authentication). For the second request URL, you must authenticate.
To test these URLs with cURL, use the following commands:
...