Chapter 8. REST API
8.1. Overview
8.1.1. Base URL
- Anonymous Base URL
http://<host>:<port>/rest/managed-components/api- Authenticated Base URL
http://<host>:<port>/rest/private/managed-components/api
8.1.2. Authentication
curl -u <username> http://<host>:<port>/rest/private/managed-components/apiNote
/platform/administrators are allowed to add, update, or delete resources.
8.1.3. Content Type
Accept: application/json
Content-Type: application/json
8.1.4. Localization
Accept-Language header to the HTTP request.
Example 8.1. French Header
Accept-Language: fr
8.2. Resources
Important
8.2.1. Sites
8.2.1.1. List Sites
site-type can be site , space , or dashboard .
Example 8.2. Listing Sites using GET
GET /api/{site-type}s/
Note
/api/spaces/ and dashboard resolves to /api/dashboards/.
Table 8.1. Additional Parameters for site-type
|
Parameter
|
Type
|
Default
|
Description
|
|---|---|---|---|
|
emptySites
|
boolean
|
false
|
Indicates to include empty sites (sites w/out pages or navigation)
|
|
offset
|
int
|
0
|
The offset of the results in a paginated request
|
|
limit
|
int
|
15
|
The maximum number of results to return in a paginated request
|
Example 8.3. List Sites using GET Request and Response
GET /api/sites
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"name" : "classic",
"type" : "site",
"url" : "/api/sites/classic"
},
{
"name" : "mobile",
"type" : "site",
"url" : "/api/sites/mobile"
}
]
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.1.2. Retrieve a Site
site-name the following syntax applies.
GET /api/{site-type}s/{site-name}
Example 8.4. Retrieve a Site Request and Response
GET /api/sites/classic
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "classic",
"type" : "site",
"displayName" : "Classic",
"description" : "GateIn default portal",
"skin" : "Default",
"locale" : "en",
"access-permissions" : ["Everyone"],
"edit-permissions" : ["*:/platform/administrators"],
"attributes" : [
{
"key" : "showPortletInfo",
"value" : "false"
},
{
"key" : "sessionAlive",
"value" : "onDemand"
}
],
"pages" : {"url" : "/api/sites/classic/pages"},
"navigation" : {"url" : "/api/sites/classic/navigation"}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.1.3. Create a site
site-name, the following syntax applies:
POST /api/{site-type}s/{site-name}
Example 8.5. Create a Site Request and Response
POST /api/sites/foo
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "foo",
"type" : "site",
"displayName" : "Basic Portal",
"description" : "This is basic portal template",
"skin" : "Default",
"locale" : "en",
"access-permissions" : ["Everyone"],
"edit-permissions" : ["*:/platform/administrators"],
"attributes" : [{
"key" : "sessionAlive",
"value" : "onDemand"
}],
"pages" : {"url" : "/api/sites/foo/pages"},
"navigation" : {"url" : "/api/sites/foo/navigation"}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.1.4. Delete a site
site-name, the following syntax applies:
DELETE /api/{site-type}s/{site-name}
Example 8.6. Delete a Site Request and Response
DELETE /api/sites/foo
HTTP/1.1 200 OK Content-Type: application/json
8.2.1.5. Update a site
site-name, the following syntax applies:
PUT /api/{site-type}s/{site-name}
Example 8.7. Update a Site Request and Response
PUT /api/sites/classic
Content-Type: application/json
{
"description" : "The Classic site shipped with the product"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "classic",
"type" : "site",
"displayName" : "Classic",
"description" : "The Classic site shipped with the product !",
"skin" : "Default",
"locale" : "en",
"access-permissions" : ["Everyone"],
"edit-permissions" : ["*:/platform/administrators"],
"attributes" : [
{
"key" : "showPortletInfo",
"value" : "false"
},
{
"key" : "sessionAlive",
"value" : "onDemand"
}
],
"pages" : {"url" : "/api/sites/classic/pages"},
"navigation" : {"url" : "/api/sites/classic/navigation"}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.2. Pages
8.2.2.1. List Pages
site-name, the following syntax applies:
GET /api/{site-type}s/{site-name}/pages
Table 8.2. list-pages Additional Attributes
|
Parameter
|
Type
|
Default
|
Description
|
|---|---|---|---|
|
offset
|
int
|
0
|
The offset of the results in a paginated request
|
|
limit
|
int
|
15
|
The maximum number of results to return in a paginated request
|
Example 8.8. List all Pages Request and Response
GET /api/sites/classic/pages
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"name" : "homepage",
"siteType" : "site",
"siteName" : "classic",
"url" : "/api/sites/classic/pages/homepage"
},
{
"name" : "register",
"siteType" : "site",
"siteName" : "classic",
"url" : "/api/sites/classic/pages/register"
},
{
"name" : "sitemap",
"siteType" : "site",
"siteName" : "classic",
"url" : "/api/sites/classic/pages/sitemap"
}
]
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.2.2. Retrieve a page
page-name, the following syntax applies:
GET /api/{site-type}s/{site-name}/pages/{page-name}
Example 8.9. Retrieve a Page Request and Response
GET /api/sites/classic/pages/homepage
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "homepage",
"displayName" : "Home Page",
"description" : null,
"access-permissions" : ["Everyone"],
"edit-permissions" : ["*:/platform/administrators"]
}
8.2.2.3. Create a page
page-name, the following syntax applies:
POST /api/{site-type}s/{site-name}/pages/{page-name}
Example 8.10. Create a New Page Request and Response
POST /api/sites/classic/pages/newpage
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "newpage",
"displayName" : "newpage",
"description" : null,
"access-permissions" : ["Everyone"],
"edit-permissions" : ["*:/platform/administrators"]
}
8.2.2.4. Delete a page
page-name, the following syntax applies:
DELETE /api/{site-type}s/{site-name}/pages/{page-name}
Example 8.11. Delete a Page Request and Response
DELETE /api/sites/classic/pages/newpage
HTTP/1.1 200 OK Content-Type: application/json
8.2.2.5. Update a page
page-name, the following syntax applies:
PUT /api/{site-type}s/{site-name}/pages/{page-name}
Example 8.12. Update Page Description Request and Response
PUT /api/sites/classic/pages/homepage
Content-Type: application/json
{
"description" : "The default homepage"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "homepage",
"displayName" : "Home Page",
"description" : "The default homepage",
"access-permissions" : ["Everyone"],
"edit-permissions" : ["*:/platform/administrators"]
}
8.2.3. Navigation
8.2.3.1. Retrieve Navigation
site-name, the following syntax applies:
GET /api/{site-type}s/{site-name}/navigation
Table 8.3. Retrieve Navigation Parameters
|
Parameter
|
Type
|
Default
|
Description
|
|---|---|---|---|
|
scope
|
int
|
n/a
|
Specifies how many nodes to load (-1 for all)
|
Example 8.14. Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"priority" : 1,
"siteType" : "site",
"siteName" : "classic",
"nodes" : [
{
"name" : "home",
"url" : "/api/sites/classic/navigation/home"
},
{
"name" : "sitemap",
"url" : "/api/sites/classic/navigation/sitemap"
}
]
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
Example 8.15. Scope Parameter Request and Response
GET /api/sites/classic/navigation?scope=1
HTTP/1.1 200 OK
Content-Type: application/json
{
"priority" : 1,
"siteType" : "site",
"siteName" : "classic",
"nodes" : [
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Home",
"displayNames" : [...]
"children" : null,
"page" : {
"pageName" : "homepage",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/homepage"
}
},
{
"name" : "sitemap",
"uri" : "/portal/classic/sitemap",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "SiteMap",
"displayNames" : [...]
"children" : null,
"page" : {
"pageName" : "sitemap",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/sitemap"
}
}
]
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.3.2. Retrieve a node
node-path, the following syntax applies:
GET /api/{site-type}s/{site-name}/navigation/{node-path}
Table 8.4. Node Path Parameters
|
parameter
|
type
|
default
|
description
|
|---|---|---|---|
|
scope
|
int
|
n/a
|
Specifies how many nodes to load (-1 for all)
|
Example 8.16. Retrieve a Node Request and Response
GET /api/sites/classic/navigation/home
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Home",
"displayNames" : [...]
"children" : null,
"page" : {
"pageName" : "homepage",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/homepage"
}
}
Accept-Language header.
Example 8.17. Accept-Language Request and Response
GET /api/sites/classic/navigation/home Accept-Language: fr
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Accueil",
"displayNames" : [...]
"children" : null,
"page" : {
"pageName" : "homepage",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/homepage"
}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
8.2.3.3. Create a node
node-path, the following syntax applies:
POST /api/{site-type}s/{site-name}/navigation/{node-path}
Example 8.18. Create a Node Request and Response
POST /api/sites/classic/navigation/home/newnode
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "newnode",
"uri" : "/portal/classic/home/newnode",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "newnode",
"children" : null,
"page" : null
}
8.2.3.4. Delete a node
node-path, the following syntax applies:
DELETE /api/{site-type}s/{site-name}/navigation/{node-path}
Example 8.19. Delete Node Request and Response
DELETE /api/sites/classic/navigation/home/newnode
HTTP/1.1 200 OK Content-Type: application/json
8.2.3.5. Update a node
node-path, the following syntax applies:
PUT /api/{site-type}s/{site-name}/navigation/{node-path}
Example 8.20. Update Node Request and Response
PUT /api/sites/classic/navigation/home
Content-Type: application/json
{
"page" : {
"pageName" : "sitemap",
"siteName" : "classic",
"siteType" : "site"
}
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Test",
"displayNames" : [...]
"children" : null,
"page" : {
"pageName" : "sitemap",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/sitemap"
}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
Example 8.21. Update displayName Request and Response
PUT /api/sites/classic/navigation/home
Content-Type: application/json
{
"displayNames" : [
{
"value" : "ホーム",
"lang" : "ja"
},
{
"value" : "Home Page",
"lang" : "en"
},
{
"value" : "首頁",
"lang" : "zh-TW"
},
{
"value" : "Domů",
"lang" : "cs"
},
{
"value" : "Accueil",
"lang" : "fr"
},
{
"value" : "主页",
"lang" : "zh"
},
{
"value" : "Главная",
"lang" : "ru"
},
{
"value" : "ترحيب",
"lang" : "ar"
},
{
"value" : "Trang chủ",
"lang" : "vi"
},
{
"value" : "Home",
"lang" : "nl"
},
{
"value" : "Inicio",
"lang" : "es"
},
{
"value" : "Principal",
"lang" : "pt-BR"
},
{
"value" : "Startseite",
"lang" : "de"
},
{
"value" : "홈",
"lang" : "ko"
},
{
"value" : "Home",
"lang" : "it"
},
{
"value" : "Додому",
"lang" : "uk"
},
{
"value" : "गृह पृष्ठ",
"lang" : "ne"
}
]
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Home Page",
"displayNames" : [
{
"value" : "ホーム",
"lang" : "ja"
},
{
"value" : "Home Page",
"lang" : "en"
},
{
"value" : "首頁",
"lang" : "zh-TW"
},
{
"value" : "Domů",
"lang" : "cs"
},
{
"value" : "Accueil",
"lang" : "fr"
},
{
"value" : "主页",
"lang" : "zh"
},
{
"value" : "Главная",
"lang" : "ru"
},
{
"value" : "ترحيب",
"lang" : "ar"
},
{
"value" : "Trang chủ",
"lang" : "vi"
},
{
"value" : "Home",
"lang" : "nl"
},
{
"value" : "Inicio",
"lang" : "es"
},
{
"value" : "Principal",
"lang" : "pt-BR"
},
{
"value" : "Startseite",
"lang" : "de"
},
{
"value" : "홈",
"lang" : "ko"
},
{
"value" : "Home",
"lang" : "it"
},
{
"value" : "Додому",
"lang" : "uk"
},
{
"value" : "गृह पृष्ठ",
"lang" : "ne"
}
],
"children" : null,
"page" : {
"pageName" : "homepage",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/homepage"
}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
Note
Example 8.22. Deleting All Localized Display Names Except for English Request and Response
PUT /api/sites/classic/navigation/home
Content-Type: application/json
{
"displayNames" : [
{
"value" : "Home",
"lang" : "en"
}
]
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Home",
"displayNames" : [
{
"value" : "Home Page",
"lang" : "en"
}
],
"children" : null,
"page" : {
"pageName" : "homepage",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/homepage"
}
}
Note
url element is the full URL but for sake of brevity it is relative for the examples in this document.
Example 8.23. Removing Localized Display Names Request and Response
PUT /api/sites/classic/navigation/home
Content-Type: application/json
{
"displayName" : "Home"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"name" : "home",
"uri" : "/portal/classic/home",
"isVisible" : true,
"visibility" : {"status" : "VISIBLE"},
"iconName" : null,
"displayName" : "Home",
"displayNames" : [{"value" : "Home"}]
"children" : null,
"page" : {
"pageName" : "homepage",
"siteName" : "classic",
"siteType" : "site",
"url" : "/api/sites/classic/pages/homepage"
}
}
8.2.4. Working with Templates
Example 8.24. Portal Site Template
Example 8.25. Group Site Template
Example 8.26. User Site Template
8.2.4.1. Portal Site Template
PUT http://<host>:<port>/rest/private/managed-components/template/portal Content-Type: application/zip .
/portal /portal/template /portal/template/<name_of_template1> /portal/template/<name_of_template1>/navigation.xml /portal/template/<name_of_template1>/pages.xml /portal/template/<name_of_template1>/portal.xml /portal/template/<name_of_template2> /portal/template/<name_of_template2>/navigation.xml /portal/template/<name_of_template2>/pages.xml /portal/template/<name_of_template2>/portal.xml ...
Portal site template parameters
- importMode
- String with default setting as merge.Possible values:
conserve,insert,merge, andoverwrite - targetSite
- String with default value set to all sites.If this targetSite attribute is not present template is applied in all portals created from templates defined in .zip. This attribute allows to filter and define in which sites this operation is performed. This attribute can have multiple instances of itself.
Example 8.27. Create a Portal Site Using Curl Tool
$ curl -i -H "Content-Type: application/zip" -u root:gtn -X PUT -T "template-templateA.zip" http://localhost:8080/rest/private/managed-components/template/portal?importMode=merge&targetSite=site1&targetSite=site2
Where template-templateA.zip: portal/template/templateA/navigation.xml portal/template/templateA/pages.xml portal/tempalte/templateA/portal.xml
Result: Updates only site1 and site2 of sites created from templateA.
8.2.4.2. Group Sites Template
PUT http://<host>:<port>/rest/private/managed-components/template/group Content-Type: application/zip
//group /group/template /group/template/navigation.xml /group/template/pages.xml /group/template/group.xml ...
Group site template parameters
- importMode
- String with default setting as merge.Data import strategy. Possible values:
conserve,insert,merge,overwrite - targetSite
- String with default value set to all sites.If this targetGroup attribute is not present template is applied in all group sites. This attribute allows to filter and define the sites on which this operation is performed. This attribute can have multiple instances of itself.
Example 8.28. Create Group Site using Curl Tool
$ curl -i -H "Content-Type: application/zip" -u root:gtn -X PUT -T "template-group.zip" http://localhost:8080/rest/private/managed-components/template/group?importMode=merge&targetGroup=myorg/mygroup1&targetGroup=myorg/mygroup2
Where template-group.zip: group/template/navigation.xml group/template/pages.xml group/tempalte/group.xml
Result: "myorg/mygroup1" and "myorg/mygroup2" groups sites created are updated with MERGE strategy using template defined in template-group.zip.
8.2.4.3. User Sites Template
PUT http://<host>:<port>/rest/private/managed-components/template/user Content-Type: application/zip
/user /user/template /user/template/navigation.xml /user/template/pages.xml /user/template/user.xml ...
Group site template parameters
- importMode
- String with default setting as merge.Data import strategy. Possible values:
conserve,insert,merge, andoverwrite - targetExpr
- String with default value set to all users.This attribute defines a search expression for user sites on which the template operation is performed. This attribute has priority over targetUser attribute.
- targetUser
- Is a String with default value set to all users.If targetExpr is not defined, targetUser can define user target for template operation. This attribute can have multiple instances.
- dashboardMode
- String with default value set to none.Creates dashboard for user. If this attribute is not present template is applied on users with a dashboard. Possible values: create.
Example 8.29. User Site using Curl Tool
$ curl -i -H "Content-Type: application/zip" -u root:gtn -X PUT -T "template-user.zip" http://localhost:8080/rest/private/managed-components/template/user?importMode=merge&targetExpr=user*
Where template-user.zip: user/template/navigation.xml user/template/pages.xml user/template/user.xml
Result: All dashboards from users starting with "user" updated with MERGE strategy using template defined in template-user.zip