Sitevision provides a built-in Model REST API that operates on the JCR data tree model that is also accessible via the Sitevision Public API. The authentication and permissions that are required to access the data via the REST API is exactly the same as it is in the Sitevision editor and via the Public API.
The Model REST API is bundled with all Sitevision installations, but it must be explicitly activated on the website. The Model REST API can be activated under the site settings in the Sitevision editor.
The REST API settings is available via the Site settings
Enabling the REST API also exposes the REST API documentation to all users that has the DEVELOPER permission!
REST API documentation overview
Be sure to log on to the website and ensure your user has the DEVELOPER permission. The REST API documentation for your REST API-enabled website is available at:
<protocol> :// <domain> / rest-api / doc
When you enter the REST API documentation you see the Nodes view. The JCR Model tree can be browsed via the links in the left menu. All available Methods/Operations will be displayed for each Node you navigate to.
REST API documentation for the Online index
When you have browsed to a Node in the JCR Model tree and selected a Method/Operation, its documentation is displayed. The documentation specifies the supported http verbs (GET, POST, PUT, DELETE) and the data requirements. It often also gives an example of input data and the corresponding JSON result.
REST API documentation for the Search method on the Online index
Each node and endpoint has two different URLs that can be used.
There are two REST API URLs to each endpoint
The pattern of a REST API URL is:
<protocol> :// <domain> / rest-api / <api version> / <model version> / <path | identifier> / <method>
Where:
Example:
https://mydomain.se/rest-api/1/1/303.online-7.0/search
The <model version> should typically be 1 ("online") in a REST URL when used externally!
=> External invokers of the REST API should typically behave as typical site visitors, i.e. use the "online" model version (1).
Example:
https://mydomain.se/rest-api/1/1/303.online-7.0/search
The parts of a JCR Node Path-based URL contains JCR Node Names (as of javax.jcr.Node.getName() values). Note that not all chars are allowed in a JCR Node Name! The JSR 283 specification states that these chars are forbidden and must be replaced:
Illegal character | Substitution character |
---|---|
/ (U+002F) "slash" | U+F02F |
* (U+002A) "asterix" | U+F02A |
: (U+003A) "colon" | U+F03A |
[ (U+005B) "left bracket" | U+F05B |
] (U+005D) "right bracket" | U+F05D |
| (U+007C) "pipe" | U+F07C |
Hence, you can never have a name like "some/name
" as part when using the Path-based URL to invoke the REST API. That name is simply not a JCR Node Name! The proper name to use would be something like "somename
" (i.e. the presumed slash should be a U+F02F character).
Sitevision tries to be lenient and forgiving even if a part of a Path-based REST API URL contains illegal characters. As a precaution, all potential illegal characters will be substituted using EndecUtil.escapeJcrName before the final resource is resolved. This will handle some invalid (non-JCR) names but some cases simply can not be solved by Sitevision:
The JCR Identifier-based URL contains a Node Identifier (as of javax.jcr.Node.getIdentifier() value).
Always use the Identifier-based URL whenever possible!
The Identifier-based URL is significantly faster than the path-based URL and it is also safer since it guarantees there will never be a name collision!
The REST API Console can be used to test invocations of REST API endpoints.
The REST API Console parts
Example of REST API Console usage