After installing and configuring, we will check content is properly served as JSON from both REST endpoints and the /json page node.
Testing the REST endpoints
To test the endpoints we use swagger tools which are included in Magnolia in the REST Tools module.
=> http://localhost:8080/magnoliaAuthor/.magnolia/admincentral#app:restTools:;
Test nodes endpoint - The nodes API v.1
Example:
Resource | /properties/v1/{workspace}{path:(/.+)?} | |
parameters | workspace | cameracollection |
path | /cameras/F3 /makers/Rollei | |
Figure out the parameters to add to get the list of all makers or all cameras on the nodes API.
Test the custom endpoint - The camera collection API v.1
makers
Resource | /cameracollection/v1/makers{makerPath:(/.+)?} | |
parameters | makerPath | /Rollei |
makerById
Resource | /cameracollection/v1/makerById/{uuid} | |
parameters | uuid | 723040c9-2f1b-4d88-8569-bbd9a57277cc |
allMakers
Resource | /cameracollection/v1/allCameras | |
parameters | - | - |
cameras
Resource | /cameracollection/v1/cameras{cameraPath:(/.+)?} | ||
parameters | cameraPath | /F3 | |
cameraById
Resource | /cameracollection/v1/cameraById/{uuid} | |
parameters | uuid | 7e0940e1-9ac0-47e9-af45-52cbd2559a1a |
allCameras
Resource | /cameracollection/v1/allCameras | |
parameters | - | - |
Testing the template-based JSON "provider"
URI pattern | URL |
---|---|
$/cameras{ cameraPath:(/.+)?} | http://localhost:8080/magnoliaAuthor/json/cameras/F3 |
$/cameraById/{uuid} | http://localhost:8080/magnoliaAuthor/json/cameraById/7e0940e1-9ac0-47e9-af45-52cbd2559a1a |
$/allCameras | http://localhost:8080/magnoliaAuthor/json/allCameras |
$/makers{makerPath:(/.+)?} | http://localhost:8080/magnoliaAuthor/json/makers/Rollei |
$/makerById/{uuid} | http://localhost:8080/magnoliaAuthor/json/makerById/723040c9-2f1b-4d88-8569-bbd9a57277cc |
$/allMakers | http://localhost:8080/magnoliaAuthor/json/allMakers |
Testing the JSON "providers" with cURL
cURL is always an alternative to test both the real REST endpoints and the template-based JSON providers. However, it requires that you have cURL installed.
Example on nodes
endpoint
curl -H "Accept: application/json" http://localhost:8080/magnoliaAuthor/.rest/nodes/v1/cameracollection/cameras/F3 -u superuser:superuser
Example on cameracollection
endpoint
curl -H "Accept: application/json" http://localhost:8080/magnoliaAuthor/.rest/cameracollection/v1/allCameras -u superuser:superuser
Example on template / virtualUri / /json
curl -H "Accept: application/json" http://localhost:8080/magnoliaAuthor/json/cameras/F3 -u superuser:superuser