Using the Page REST API
Intro:
This document will explain what you can do with the page REST API to help edit content within CM1. It will cover how to retrieve, create, and edit Pages.
NOTE: When sending requests to the server they should all be of type application/json.
Get a Page
Functionality:This REST call will allow you to retrieve a page from your CM1 instance.
What you need to know:
- The name of the site that the page is in
- The name of the page you want to retrieve
- Optionally the Path from the site to the page
Use Case:
You need the information about the page object.
How to execute:
Execute a GET request against the CM1 instance (http://myCM1:9992) with the name of the site (MySite) and the name of the page (MyFirstPage).
Example #1:
GET http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyFirstPage
Example #2:
GET http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyFolder/MyFirstPage
Response:
The JSON Response may look like this on a fresh page with no content built in:
NOTE: The template used in this example page is the default “Box” Percussion template (MyTemplate). This defines the structure of the body object within the response JSON. Each JSON object in the body is considered a region and lines up with a piece of the template.
{
"id":"16777215-101-4156",
"name":"MyPage",
"siteName":"MySite",
"folderPath":"",
"displayName":"MyPage",
"templateName":"MyTemplate",
"summary":"",
"overridePostDate":null,
"workflow":{
"name":"Default Workflow",
"state":"Draft",
"checkedOut":true,
"checkedOutUser":"Admin"
},
"seo":{
"browserTitle":"MyPage",
"hideSearch":false,
"tags":[ ],
"categories":[ ]
},
"calendar":{
"startDate":null,
"endDate":null,
"calendars":null
},
"code":{ },
"body":[
{
"name":"footer",
"type":"TEMPLATE",
"editable":true,
"widgets":[ ]
},
{
"name":"content",
"type":"TEMPLATE",
"editable":true,
"widgets":[ ]
},
{
"name":"leftsidebar",
"type":"TEMPLATE",
"editable":true,
"widgets":[ ]
},
{
"name":"container",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"middle",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"header",
"type":"TEMPLATE",
"editable":true,
"widgets":[ ]
},
{
"name":"percRoot",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"rightsidebar",
"type":"TEMPLATE",
"editable":true,
"widgets":[ ]
}
]
}
Create a Page
Functionality:
This REST call will allow you to create a page in your CM1 instance.
What you need to know:
- The name of the site that you want to create the page in
- The name of the page you want to create
- Optionally the Path from the site to the page
Use Case:
You need to create a page object.
How to execute:
Execute a PUT request against the CM1 instance (http://myCM1:9992) with the name of the site (MySite) and the name of the page (MyNewPage).
Example #1:
This example shows the easiest way to create a page using the smallest payload possible which happens to require only the templateName field.
PUT http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyNewPage
Payload:
NOTE: If you include the id when you execute a PUT it must match the id of the object at the specified PUT URL. If you are creating a new object you should not include the id.
{ "templateName":"MyTemplate" }
Example #2:
This example shows the extensive payload structure in creating a page and all the fields you may specify:
PUT http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyFolder/MyNewPage
Payload:
NOTE: If you include the id when you execute a PUT it must match the id of the object at the specified PUT URL. If you are creating a new object you should not include the id.
- name, siteName, and folderPath all correlate to the location of the page. Please note that these fields do not need to be specified on a PUT as they are covered in the PUT URL. If you choose to specify them it must match the value in the PUT URL otherwise an error will be thrown.
- workflow correlates to the workflow in CM1
- name correlates to the name of the workflow where Default Workflow translates to the currently selected default workflow in CM1.
- state correlates to what state the page is in within the selected workflow.
- checkedOut correlates to whether or not the page is checked out by a user.
- checkedOutUser correlates to what user has the page checked out.
- templateName correlates to the template that will be used for the homepage within the site.
- summary correlates to the summary of what the page is, a brief description of the page.
- overridePostDate correlates to if you want to set a page to the date it was actually created instead of the date it was imported into CM1.
- seo correlates to the seo and metadata aspects of the page such as:
- browserTitle translates to the title the browser will perceive the page as.
- hideSearch sets the page to searchable or non-searchable.
- tags is a list of keywords that help identify the contents of the page in the metadata.
- categories is a list of keywords that help identify the type of content on the page.
- calendar is a pretty straight forward object that tracks time on the page. This can be used to expire a page at a certain date.
- code correlates to all of the code on the page.
- body is the main content of the page and uses the template assigned to the page to develop the structure and layout. It is a list of regions defined by the template and contain a name, type, a flag editable which denotes that it can be edited, and a list of widgets (see Create Content in Page for widgets). Not all regions have to be specified, only the ones you would like to add content to.
{
"name":"MyNewPage",
"siteName":"MySite",
"folderPath":"",
"displayName":"MyNewPage",
"templateName":"MyTemplate",
"summary":null,
"overridePostDate":null,
"workflow":{
"name":"Default Workflow",
"state":"Draft",
"checkedOut":true,
"checkedOutUser":"Admin"
},
"seo":{
"browserTitle":"MyNewPage",
"hideSearch":false,
"tags":[ ],
"categories":[ ]
},
"calendar":{
"startDate":null,
"endDate":null,
"calendars":null
},
"code":{ },
"body":[
{
"name":"footer",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"content",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"leftsidebar",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"container",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"middle",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"header",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"percRoot",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"rightsidebar",
"type":"PAGE",
"editable":true,
"widgets":[ ]
}
]
}
Response:
The JSON response will be a JSON structure of the page you passed in with the body formatted to the template (See Get Page for an example).
NOTE: The template used in this example page is the default “Box” Percussion template (MyTemplate). This defines the structure of the body object within the response JSON. Each JSON object in the body is considered a region and lines up with a piece of the template.
Update a Page
Functionality:
This REST call will allow you to update a page in your CM1 instance.
What you need to know:
- The name of the site that the page is in that you want to update
- The name of the page you want to update
- Optionally the Path from the site to the page
Use Case:
You need to update a page object.
How to execute:
Execute a PUT request against the CM1 instance (http://myCM1:9992) with the name of the site (MySite) and the name of the page (MyPage).
Example:
This example shows the extensive payload structure in updating a page and all the fields you may specify. Note that the template field is required.
PUT http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyFolder/MyPage
Payload:
NOTE: If you include the id when you execute a PUT it must match the id of the object at the specified PUT URL. If you are creating a new object you should not include the id. Note that not all fields have to be specified, only those that you want to update.
- name, siteName, and folderPath all correlate to the location of the page. Please note that these fields do not need to be specified on a PUT as they are covered in the PUT URL. If you choose to specify them it must match the value in the PUT URL otherwise an error will be thrown.
- workflow correlates to the workflow in CM1
- name correlates to the name of the workflow where Default Workflow translates to the currently selected default workflow in CM1.
- state correlates to what state the page is in within the selected workflow.
- checkedOut correlates to whether or not the page is checked out by a user.
- checkedOutUser correlates to what user has the page checked out.
- templateName correlates to the template that will be used for the homepage within the site.
- summary correlates to the summary of what the page is, a brief description of the page.
- overridePostDate correlates to if you want to set a page to the date it was actually created instead of the date it was imported into CM1.
- seo correlates to the seo and metadata aspects of the page such as:
- browserTitle translates to the title the browser will perceive the page as.
- hideSearch sets the page to searchable or non-searchable.
- tags is a list of keywords that help identify the contents of the page in the metadata.
- categories is a list of keywords that help identify the type of content on the page.
- calendar is a pretty straight forward object that tracks time on the page. This can be used to expire a page at a certain date.
- code correlates to all of the code on the page.
- body is the main content of the page and uses the template assigned to the page to develop the structure and layout. It is a list of regions defined by the template and contain a name, type, a flag editable which denotes that it can be edited, and a list of widgets (see Create Content in Page for widgets). Not all regions have to be specified, only the ones you would like to add content to.
{
"name":"MyPage",
"siteName":"MySite",
"folderPath":"",
"displayName":"MyPage",
"templateName":"MyTemplate",
"summary":null,
"overridePostDate":null,
"workflow":{
"name":"Default Workflow",
"state":"Draft",
"checkedOut":true,
"checkedOutUser":"Admin"
},
"seo":{
"browserTitle":"MyPage",
"hideSearch":false,
"tags":[ ],
"categories":[ ]
},
"calendar":{
"startDate":null,
"endDate":null,
"calendars":null
},
"code":{ },
"body":[
{
"name":"footer",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"content",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"leftsidebar",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"container",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"middle",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"header",
"type":"PAGE",
"editable":true,
"widgets":[ ]
},
{
"name":"percRoot",
"type":"TEMPLATE",
"editable":false,
"widgets":[ ]
},
{
"name":"rightsidebar",
"type":"PAGE",
"editable":true,
"widgets":[ ]
}
]
}
Response:
The JSON response will be a JSON structure of the page you passed in with the body formatted to the template (See Get Page for an example).
NOTE: The template used in this example page is the default “Box” Percussion template (MyTemplate). This defines the structure of the body object within the response JSON. Each JSON object in the body is considered a region and lines up with a piece of the template.
Update/Create Content in a Page
Functionality:
This REST call will allow you to create content and update a page in your CM1 instance.
What you need to know:
- The name of the site that the page is in that you want to update
- The name of the page you want to update
- Optionally the Path from the site to the page
Use Case:
You need to update a page object.
How to execute:
Execute a PUT request against the CM1 instance (http://myCM1:9992) with the name of the site (MySite) and the name of the page (MyPage).
Example:
This example shows how to put simple content into a page.
PUT http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyFolder/MyPage
Payload:
NOTE: If you include the id when you execute a PUT it must match the id of the object at the specified PUT URL. If you are creating a new object you should not include the id. Note that not all fields have to be specified, only those that you want to update.
- (See Create Page for more details on fields)
- body is the main content of the page and uses the template assigned to the page to develop the structure and layout. It is a list of regions defined by the template and contain a name, type, a flag editable which denotes that it can be edited, and a list of widgets. Each widget contains:
- type correlates to the type of widget (See list of widgets at the bottom of this document)
- scope correlates to where the widget is either local (on the page) or template (on the template).
- editable correlates to whether or not the template is editable.
- asset holds a map of fields for the widget.
- fields is a map of fields each widget having their own key values much like percRichText has a key “text” to contain the content of the rich text.
- If only fields is specified the asset will be a local asset, tied to the page. Local assets are not found within the Assets folder and do not have their own workflow.
- If the asset contains the
{
"name":"MyPage",
"siteName":"MySite",
"folderPath":"",
"displayName":"MyPage",
"templateName":"MyTemplate",
"body":[
{
"name":"header",
"type":"PAGE",
"editable":true,
"widgets":[
{
"type":"percRichText",
"scope":"local",
"editable":true
"asset": {
"fields": {
"text": "<div class=\"rxbodyfield\"><p>TESTING HELLO WORLD</p></div>"
}
}
}
]
}
]
}
If the asset element contains just fields it will be a local asset that is tied to the page and the page workflow. A local asset can be converted to a shared asset by specifying a name and folderPath. An existing shared asset can be linked by using the name and folderPath in the same way.
Note. Shared asset fields are read only from the page API, you can only relate to the existing shared asset and read its data in a GET. Editing of the shared asset must be done through the asset api.
"asset": {
"fields": {
"text": "<div class=\"rxbodyfield\"><p>TESTING HELLO WORLD</p></div>"
}
},
"name": "name-in-finder",
"folderPath": "Assets/test",
{
Response:
The JSON response will be a JSON structure of the page you passed in with the body formatted to the template (See Get Page for an example).
NOTE: The template used in this example page is the default “Box” Percussion template (MyTemplate). This defines the structure of the body object within the response JSON. Each JSON object in the body is considered a region and lines up with a piece of the template.
Delete a Page
Functionality:
This REST call will allow you to delete a page in your CM1 instance.
What you need to know:
- The name of the site the page is in that you want to delete
- The name of the page you want to delete
- Optionally the Path from the site to the page
Use Case:
You need to delete a page object.
How to execute:
Execute a DELETE request against the CM1 instance (http://myCM1:9992) with the name of the site (MySite) and the name of the page (MyPage).
Example:
DELETE http://myCM1:9992/Rhythmyx/rest/pages/by-path/MySite/MyFolder/MyPage
Response:
{"message":"Deleted"}
List of widget types:
percRawHtml
percRichText
percSimpleText
percNavImage
percNavon
percNavTree
percEvent
percFile
percFileAutoList
percFlash
percForm
percCommentsForm
percPageAutoList
percBlogIndex
percTagList
percCategoryList
percCalendar
percArchiveList
percImageAutoList
percTitle
percBlogPost
percRss
percLogin
percRegistration
percPoll
percSecureLogin
percImage