Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
...
When using a preconfigured preconfigured Magnolia bundle - your webapp(s) already contain(s) these three modules. When using a custom webapp or bundle, make sure your custom setup contains the module listed above. See REST module - Installing if you need help to install the Magnolia REST modules.
While developing new features, it can be helpful to use the magnolia-rest-tools
which enable the swagger UI tools. Have a look at enabling swagger UI tools.
...
Expand | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||
#1 Get the shell and choose a directory to work withOpen a shell and change to directory of your choice. In our example, we use the directory
#2 Downloading a bundle with CLI jumpstart
Jumpstart downloads and extracts the latest version of Jumpstart also sets the property When the execution of jumpstart is done, your directory looks like this:
We will need the #3 Adding the magnolia-rest tools to the bundleDownload the Rest tools bundle
~/dev/mgnl-rest-test-base/apache-tomcat/webapps/magnoliaAuthor/WEB-INF/lib . Some of the files may already be there, that's fine.#4 Start MagnoliaYou are ready to start Magnolia - actually the Tomcat server - for the first time. Go to our "root" directory ans start with and execute the CLI command
Give Magnolia some time. On the first start up Magnolia installs some configurations for a bunch of modules, etc. pp.lot of configuration data and demo content bootsrapped with its modules. #5 Login on the author contextOpen your favorite browser, open the URL http://localhost:8080/magnoliaAuthor/ and login as user #6 Set the swagger base api pathIn order to properly use the swagger UI tools - which are used for development only - we must adapt one property in the configuration. On the UAdmin - open the Configuration app and open the node Open the folder This property is one of the rare one which requires a server restart to make the change effective. #7 Restart MagnoliaGo to the shell where you have started Magnolia. To stop the server - press Now start it again:
|
...
superuser
on the author context - for testing reasons only!On the author context use the superuser is granted:
...
Note that superuser is given a lot of power. Use it carefully in the context of this tutorial. But never use superuser on a productive environment for REST.
anonymous
user on the public context...
If you want to use REST to create, update and delete content - we recommend using the Nodes endpoint which supports all required operations. If you mainly want to read data - consider using the Delivery endpoint. It provides a very handy formatted JSON and can be customized and configured with YAML via light module. With the Commands endpoint you can trigger commands. And <TODO: Add link to: Cache endpoint> deals Cache endpoint deals with cache. And you always can create ypur your own custom endpoints - for inspiration see How to create a custom Java based REST endpoint.
...
cURL
is a command line tool. It can be used on most of the well known operating systems. In this tutorial we will often test REST request via cURL.
Download | https://curl.haxx.se/download.html |
Positive | Very flexible to tailor the request (method, request headers, user credentials, etc.). Response can be further processed. |
Negative | Not everybody likes command line tools. The response is not reasy easy to read without further tooling. No out of the box automatic URL encoding. |
Tips | On the first atempt 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 the swagger UI tools, skip this section, or see above about ho how to enable the swagger tools.
...