Example Use Cases
Once the web application has been successfully deployed, the REST service is available at the following base endpoint:/rest/v1/
A complete list of available endpoints can be viewed interactively via the Swagger UI, which is available at the following address:/rest/swagger-ui/index.html
Getting started: Creating templates and managing content
The following example uses several related use cases to demonstrate how templates, pages, and content are created and edited using the REST API. A simple page on the topic of 'coffee' serves as the example project.
Create a project
You can create a new project using the following endpoint:
/rest/v1/projects/
POST /rest/v1/projects/
Content-Type: application/json
{
"name": "Coffee Times",
"description": "The latest news from the world of coffee."
}
The return value contains the project ID.
{
"id": 548532,
"uuid": "bf04cb12-add0-4a59-8d05-5765d3b85d66",
"name": "Coffee Times",
"description": "The latest news from the world of coffee."
}
Create a section template
The home page should display a series of articles. Each article consists of a headline and a content section. First, create a section template:
POST /v1/projects/548532/templates/section-templates/
Content-Type: application/json
{
"uid": "article",
"name": "News Article",
"description": "A single article about coffee"
}
Next, add form elements for the heading and the content area. Note that the GOM definition must be passed with the correct content type, application/xml.
POST /v1/projects/548532/templates/section-templates/article/gom
Content-Type: application/xml
<CMS_MODULE>
<CMS_INPUT_TEXT name="st_headline" useLanguages="yes">
<LANGINFOS>
<LANGINFO lang="*" label="Text" description="Headline of the article"/>
</LANGINFOS>
</CMS_INPUT_TEXT>
<CMS_INPUT_DOM name="st_content" useLanguages="yes">
<LANGINFOS>
<LANGINFO lang="*" label="Content" description="Article content"/>
</LANGINFOS>
</CMS_INPUT_DOM>
</CMS_MODULE>
The content is rendered via the default HTML output channel.
GET /v1/projects/548620/template-sets/html
{
"uid": "html",
"extension": "html",
"conversionTable": "Convert HTML",
"active": true,
"templateInspectionEnabled": true
}
Since output channels can contain various formats, they are defined as "text/plain."
PUT /v1/projects/548532/templates/section-templates/article/channel-sources/html
Content-Type: text/plain
<div class="article">
<h1>$CMS_VALUE(st_headline)$</h1>
$CMS_VALUE(st_content)$
</div>
Create a page template
The individual articles should be displayed one below the other on the homepage. Create a page template:
POST /v1/projects/548620/templates/page-templates/
Content-Type: application/json
{
"uid": "homepage",
"name": "Homepage",
"description": "List of all articles",
"bodies": [
{
"name": "main",
"allowedTemplates": ["article"]
}
]
}
An introductory text should appear at the top of the home page. Create additional form fields for the page accordingly:
PUT /v1/projects/548532/templates/page-templates/homepage/gom
Content-Type: application/xml
<CMS_MODULE>
<CMS_INPUT_TEXT name="pt_title"useLanguages="yes">
<LANGINFOS>
<LANGINFO lang="*" label="Title" description="Title of the page"/>
</LANGINFOS>
</CMS_INPUT_TEXT>
<CMS_INPUT_TEXT name="pt_preface"useLanguages="yes">
<LANGINFOS>
<LANGINFO lang="*" label="Preface" description="A short introduction"/>
</LANGINFOS>
</CMS_INPUT_TEXT>
</CMS_MODULE>
PUT /v1/projects/548532/templates/page-templates/homepage/channel-sources/html
Content-Type: text/plain
<html>
<head>
<title>$CMS_VALUE(pt_title)$</title>
</head>
<body>
<h1>$CMS_VALUE(pt_title)$</h1>
$CMS_VALUE(pt_preface)$
$CMS_VALUE(#global.page.body("main"))$
</body>
</html>
Create a page
Once the template is ready, create a page:
POST /v1/projects/548532/pages/
Content-Type: application/json
{
"uid": "homepage",
"templateUid": "homepage"
}
PATCH /v1/projects/548532/pages/homepage/form/pt_title
Content-Type: application/json
{
"name": "pt_title",
"type": "CMS_INPUT_TEXT",
"content": "Coffee Times"
}
PATCH /v1/projects/548532/pages/homepage/form/pt_preface
Content-Type: application/json
{
"name": "pt_preface",
"type": "CMS_INPUT_DOM",
"content": "<i>Coffee Times</i> is your dedicated source for news, trends, and stories from the world of coffee — for enthusiasts and professionals alike."
}
Add articles
You can now add as many articles as you like to the "main" content section:
PUT /v1/projects/548532/pages/homepage/bodies/main/sections/Columbian%20Harvest
Content-Type: application/json
{
"templateUid": "article"
}
PATCH /v1/projects/548532/pages/homepage/bodies/main/sections/Columbian%20Harvest/form/st_headline
Content-Type: application/json
{
"name": "st_headline",
"type": "CMS_INPUT_TEXT",
"content": "Colombian Harvest Reaches Record High"
}
PATCH /v1/projects/548532/pages/homepage/bodies/main/sections/Columbian%20Harvest/form/st_content
Content-Type: application/json
{
"name": "st_content",
"type": "CMS_INPUT_DOM",
"content": "Coffee farmers in Colombia have reported an exceptional harvest this season, with production figures surpassing all previous records."
}
Release page
Once you have finished editing the content, you can release the page:
POST /v1/projects/548532/pages/homepage/actions
Content-Type: application/json
{
"action": "release",
"options": {
"checkOnly": false,
"dependentReleaseType": "NO_DEPENDENT_RELEASE",
"ensureAccessibility": false,
"recursive": false
}
}
Create a page reference
To ensure that the page is generated in the correct location, you must create an appropriate reference:
To create the reference, you'll need the page ID.
GET /v1/projects/548532/pages/homepage
{
"id": 548581,
"gid": "6e226dc4-f91d-4ddb-93bb-285c6b3f4f09",
"projectId": 548532,
"uid": "homepage",
[...]
}
POST /v1/projects/548532/page-references/
Content-Type: application/json
{
"uid": "homepage",
"pageId": 548581,
"location": "/"
}
Finally, also release the page reference:
POST /v1/projects/548532/page-references/homepage/actions
Content-Type: application/json
{
"action": "release",
"options": {
"checkOnly": false,
"dependentReleaseType": "NO_DEPENDENT_RELEASE",
"ensureAccessibility": false,
"recursive": false
}
}