The Content Management Servce (CMS) REST API is a service that provides a collection of methods used to manage electronic files, documents and other data that could be identified as content.
Basic structure
You can create a call the Content service via an HTTP request. The URL template for this service is:
{server}/CMS.WebService/CMSServiceRest.svc/{command}/{domain}?t={token}&u={path}
The following parameters are standard for most of the supported commands.
Parameter | Description |
---|---|
u | The path of the folder or file that you want to either create or do something with. It can be in either in CMS direct link or as a relative URL. CMS direct link example: CMS:///parentFolder/newSubFolder CMS:///parentFolder/newSubFolder/myDocument.docx Relative URL example: /parentFolder/newSubFolder /parentFolder/newSubFolder/myDocument.docx |
t | The security token generated upon login |
Supported Commands
Text
Create folder
You can create a new folder via an HTTP GET request that looks like:
{server}/CMS.WebService/CMSServiceRest.svc/createFolder/{domain}?t={token}&u=/parentFolder/newSubFolder
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of where you want to create the new folder. |
Upload file to folder
This upload the file to the CMS. If the file with the target name exists already then it will overwrite it. You can upload a file to the CMS via an HTTP PUT request on the file that looks like:
{server}/CMS.WebService/CMSServiceRest.svc/createResource/{domain}?t={token}&u=/parentFolder/subFolder/myNewDocument.pdf
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of where you want to place the uploaded file. |
The request Header should have the following information:
Header | Required | Description |
---|---|---|
OriginalFileName | Yes | file / content name |
ContentType | Yes | mime type for file/content |
ContentLength | Yes | length of file / content |
Replace file in folder
You can replace a file in the the CMS via an HTTP PUT request on the file that looks like:
{server}/CMS.WebService/CMSServiceRest.svc/createResource/{domain}?t={token}&u=/parentFolder/subFolder/myExistingDocument.pdf
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of where the current file is. |
The request Header should have the following information:
Header | Required | Description |
---|---|---|
OriginalFileName | Yes | file / content name |
ContentType | Yes | mime type for file/content |
ContentLength | Yes | length of file / content |
Get a CMS node's information
You can get info of a file or folder in the the CMS via an HTTP GET request on the file that looks like:
{server}/CMS.WebService/CMSServiceRest.svc/getnode/{domain}?t={token}&u=/parentFolder/subFolder/myExistingDocument.pdf or {server}/CMS.WebService/CMSServiceRest.svc/getnode/{domain}?t={token}&u=/parentFolder/subFolder
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of the folder or file you want information of. |
If the specified path is a folder then the result looks like:
{ "Node" : { "Length" : 1497, "ContentType" : "application/pdf", "OriginalFileName" : "test2.pdf", "Buffer" : null, "CreatedDate" : "\/Date(1356662076767-0800)\/", "CreatedBy" : null, "ModifiedDate" : "\/Date(1356732643871-0800)\/", "ModifiedBy" : null }, "ErrorCode" : 0, "ErrorMessage" : null }
If the specified path is a file then the result looks like:
{ "Node" : { "Name" : "test", "CreatedDate" : "\/Date(1356661225439-0800)\/", "CreatedBy" : null, "ModifiedDate" : "\/Date(1356661225439-0800)\/", "ModifiedBy" : null }, "ErrorCode" : 0, "ErrorMessage" : null }
Download a file
You can retrieve the file content via an HTTP GET request. In the response, the byte stream is returned and the client's browser is able to process it. The URL looks like:
{server}/CMS.WebService/CMSServiceRest.svc/getResource/{domain}?t={token}&u=/parentFolder/subFolder/myExistingDocument.pdf
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of the file that you want to download. |
Delete a file
You can delete a file (if one exists) via an HTTP GET request on the file that looks like:
{server}/CMS.WebService/CMSServiceRest.svc/deleteResource/{domain}?t={token}&u=/parentFolder/subFolder/myExistingDocument.pdf
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of the file you want to delete. |
Delete a folder
You can delete a file (if one exists) via an HTTP GET request on the folder that looks like:
{server}/CMS.WebService/CMSServiceRest.svc/deleteFolder/{domain}?t={token}&u=/parentFolder/subFolder
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of the folder you want to delete. |
Download a file
You can retrieve the ZIPed file content via an HTTP GET request. In the response, the byte stream is returned and the client's browser is able to process it. The URL looks like:
{server}/CMS.WebService/CMSServiceRest.svc/zip/{domain}?t={token}&u=/parentFolder/subFolder/myExistingDocument.pdf
The parameters in that URL are:
Parameter | Description |
---|---|
u | The path of the file that you want to zip and download. |
Using this service
The most common way to use this service is from a page by making an AJAX request. You can also call this service from a rule using WCF.
JavaScript Example
Text
CURL Example
Create a folder with a simple GET:
curl.exe -v "https://my.appbase.com/CMS.WebService/CMSServiceRest.svc/createFolder/MySolution_Production.myTenant?t=twR1p8l5u3sFwMe4oiGtAXk7MCoznehUViRG1H2SHxDZmhqOkU%2fvdwf5URgklrtftkP9Zf5&u=CMS:///parentFolder/subFolder"
Upload a file on my computer to the CMS:
curl.exe -v -T "C:\SampleDocuments\Test.pdf" --header "Content-Length: 1497" --header "Content-Type: application/pdf" --header "OriginalFileName: Test.pdf" "https://my.appbase.com/CMS.WebService/CMSServiceRest.svc/createresource/MySolution_Production.myTenant?t=twR1p8l5u3sFwMe4oiGtAXk7MCoznehUViRG1H2SHxDZmhqOkU%2fvdwf5URgklrtftkP9Zf5&u=/test2.pdf"
WCF Example
Text