MHC 13.0 Create API Guide
This documentation describes the Application Programming Interfaces (API v2) for MHC Create version 13.0 (Onyx) and later.
Introducing MHC Create API 2
Using this API, software programmers are able to produce documents in high volumes and manage customer communications, according to the different MHC Create layers.
The following features are matching the MHC Create solution:
- Render documents dynamically, in real-time, using XML or JSON as input data to output formats such as PDF, HTML, Text.
- Data Integration (SQL, XML, JSON, CSV, etc.).
- Document Assembly Line (with additional inputs such as Word, Excel, PDF, TIFF, JPEG, SVG, Barcodes, Charts, 3-D Objects).
- Use document templates created in MHC Studio to control layout, styles, colors and other visual aspects.
- Implement security using users and groups(not available in core-only installations).
- Versionable repository and asset management (not available in core-only installations).
MHC Create provides the following APIs:
JavaScriptfor web programmers through the inclusion ofEngageCX.EOS.Client.2.0.jsC#for .NET programmers by adding a reference to theEngageCX.EOS.Client.2.0.NET.dllassemblyJavafor Java programmers through theEngageCX.EOS.Client.2.0.Java.jarpackage
The communication between these APIs and the MHC Create server is performed through REST endpoints via HTTP or HTTPS.
Notes
50100 (HTTP) and 50101 (HTTPS). HTTPS (port 443) access is provided.Live REST API Documentation
The REST API is accompanied by a live documentation page which allows you to send requests in real time and examine the response.
The Live REST API Inspector can be accessed via a web page under the /doc URL. For a local installation using the default ports, this would be:
- For HTTP: http://localhost:50100/doc
- For HTTPS: https://localhost:50101/doc
The default ports can be updated from the Management Console tool, by going to the Engine Settings\HTTP Server Configuration and updating the HTTP Server Port parameter, respectively HTTPS Server Port.
Getting Started
Authentication
Create uses API keys in order to authenticate requests made by clients. You have to access the Management Console to find the API Key in order to use the MHC Create API.
For core-only installations, open the Management Console, and navigate to MHC Create Engine/Engine Settings/HTTP Server Configuration/API KEY. If you are using the cloud version, these can be downloaded from the Developer\Software module, under the Programming tools and API's group section.
All endpoints require a session token. The token can be obtained using the Authorization service.
Template management
For core-only installations, templates are managed in the file system and can be found in the Management Console/Workspaces, under the default workspace. XML Document samples can be found in Start Menu under MHC Create Samples then access XML Samples. You can find here samples that prove the basic conversion capabilities of out Create tool: MHC Studio Publisher templates and XSL-FO files for XML to PDF conversion, and also DAL files use for document assembly.
Using MHC Create JavaScript API
Create comes with a feature REST API written in JavaScript that allows you to accomplish essentially anything that can be done through the user interface.
Including the library
The JavaScript API is referenced through EngageCX.EOS.Client.2.0.js. Use https://eos4.ecrion.com as the server name, however for core-only installations, make sure to use the correct server name and port number provided by your system administrator:
<html>
<head>
<script src="https://eos4.ecrion.com/sdk/v2/javascript/EngageCX.EOS.Client.2.0.js"></script>
</head>
<body>
<script>
// JavaScript code that uses the Create API
</script>
</body>
</html>
Using the API
The example below uses JavaScript to convert XML to PDF using a template stored on the Create server. An XML string is sent to the Create server and a PDF is received back:
// Wait for the API to initialize
eosAPI.ready(function(){
// Authenticate using an API key
eosAPI.authorize("API:59e80576-19e5-4808-98c0-cf2c9da055ea")
.catch(function(response){
// Handle any authentication errors here
alert("Authentication failure: " + response.statusText);
})
});
// Wait for authorize() to complete
eosAPI.authorized(function(){
// Render an xml to pdf using a template
eosAPI.DirectRender.Render({
request: {
InputSettings: {
Template: {
Workspace: "Default",
Path: "Retail/Bookstore Invoice/Invoice.epr"
}
},
Input: {
InputFormat: "xml",
Source: '<?xml version="1.0" standalone="yes"?>' +
'<root>' +
'<Invoices>' +
'<Invoice>' +
'<InvoiceProperties>' +
'<number>02116</number>' +
'<date>2016-06-10</date>' +
'</InvoiceProperties>' +
'<CustomerInformation>' +
'<name>Earl Library Co.</name>' +
'<address>1021 South Main Street, Seattle, Washington 92315</address>' +
'<email>sales@earlbook.com</email>' +
'<telephone>(206)321-2345</telephone>' +
'</CustomerInformation>' +
'<Products>' +
'<Product>' +
'<id>1</id>' +
'<name>Rendezvous with Rama by Arthur C. Clarke</name>' +
'<price>15</price>' +
'<quantity>3</quantity>' +
'<total>45</total>' +
'<description>An all-time science fiction classic, Rendezvous with Rama is also one of Clarke\'s best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.</description>' +
'</Product>' +
'</Products>' +
'<Comments>' +
'<comments>Contact us with any questions you may have.</comments>' +
'</Comments>' +
'</Invoice>' +
'</Invoices>' +
'</root>'
},
PdfOutput: {}
}
}, {
responseContentType: 'application/pdf'
})
.then(function(response) {
// PDF rendered and received. You can use response.data to retrieve the PDF bytes,
// however for this sample the previewResponse utility is used
// to quickly preview the response bytes in a new window
eosAPI.Util.previewResponse(response);
})
.catch(function(response){
// Handle any render errors here
alert("Render error: " + response.obj.Message);
});
});
Notes
obj property contains the deserialized response. data property contains the response bytes if it's binary. status property contains the HTTP status code. .ready or .authorized wrappers..authorizeWithToken utility instead of authorize.eosAPI.sessionToken.Using MHC Create .NET API
Using the .NET API is very easy and accessible for all users to retrieve and store files in the repository. The .NET assembly contains the client-side object model that needs to be downloaded by following the next section.
Downloading the API
For core-only installations, use the SDK download page, which by default is located at https://localhost:50101/sdk or http://localhost:50100/sdk.
If you are using the cloud version, these can be downloaded from the Developer\Software module, under the Programming tools and API's group section.
Using the API
In the zip file there is a README.html file that explains how to use the API.
For core-only installations, you need to make sure to use the correct server name and port number provided by your system administrator:
The code sample below uses Create API to convert XML to PDF using a template stored on the Create server. An XML string is sent to the Create server and a PDF is received back and downloaded locally.
string eosUrl = "https://eos4.ecrion.com";
string apiKey = "API:59e80576-19e5-4808-98c0-cf2c9da055ea";
string downloadFolder = "C:/Downloads/";
string fileName = "eos-sample1-xml2pdf.pdf";
try
{
AuthorizationService authSvc = new AuthorizationService(eosUrl);
string sessionToken = authSvc.GetToken(apiKey).AccessToken;
Console.WriteLine("Your token is: {0}", sessionToken);
// Render XML -> PDF
// Create a new Render API
DirectRenderService renderSvc = new DirectRenderService(eosUrl);
// Create a new render request
RenderRequestEntity request = new RenderRequestEntity()
{
InputSettings = new InputSettings()
{
Template = new Template()
{
Workspace = "Default",
Path = "Retail/Bookstore Invoice/Invoice.epr"
}
},
Input = new Input()
{
InputFormat = "xml",
Source = "<?xml version=\"1.0\" standalone=\"yes\"?>" +
"<root>" +
"<Invoices>" +
"<Invoice>" +
"<InvoiceProperties>" +
"<number>02116</number>" +
"<date>2016-06-10</date>" +
"</InvoiceProperties>" +
"<CustomerInformation>" +
"<name>Earl Library Co.</name>" +
"<address>1021 South Main Street, Seattle, Washington 92315</address>" +
"<email>sales@earlbook.com</email>" +
"<telephone>(206)321-2345</telephone>" +
"</CustomerInformation>" +
"<Products>" +
"<Product>" +
"<id>1</id>" +
"<name>Rendezvous with Rama by Arthur C. Clarke</name>" +
"<price>15</price>" +
"<quantity>3</quantity>" +
"<total>45</total>" +
"<description>An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.</description>" +
"</Product>" +
"</Products>" +
"<Comments>" +
"<comments>Contact us with any questions you may have.</comments>" +
"</Comments>" +
"</Invoice>" +
"</Invoices>" +
"</root>"
},
PdfOutput = new PdfOutput()
};
// Send the request
Stream response = renderSvc.Render(sessionToken, request);
Console.WriteLine("XML -> PDF rendered ok");
// Download the PDF locally
if (!Directory.Exists(downloadFolder))
Directory.CreateDirectory(downloadFolder);
using (System.IO.Stream newFile = System.IO.File.OpenWrite(downloadFolder + fileName))
{
response.CopyTo(newFile);
}
Console.WriteLine("Downloaded response file to folder: {0}", downloadFolder + fileName);
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
}
Using MHC Create Java API
The Java API will need the same client-side object model mentioned above written in Java.
Downloading the API
For core-only installations, use the SDK download page, which is by default located at https://localhost:50101/sdk or http://localhost:50100/sdk.
If you are using the cloud version, these can be downloaded from the Developer\Software module, under the Programming tools and API's group section.
Using the API
In the zip file there is a README.html file that explains how to use the API.
For core-only installations, you need to make sure to use the correct server name and port number provided by your system administrator:
The code snippet below uses Create API to convert XML to PDF using a template stored on the Create server. An XML string is sent to the Create server and a PDF is received back:
String eosUrl = "https://eos4.ecrion.com";
String apiKey = "API:59e80576-19e5-4808-98c0-cf2c9da055ea";
String downloadFolder = "C:/Downloads/";
String fileName = "eos-sample1-xml2pdf.pdf";
AuthorizationService authSvc = new AuthorizationService(eosUrl);
String sessionToken = authSvc.getToken(apiKey).getAccessToken();
System.out.format("Your token is: %s%n", sessionToken);
// Create a new render request
RenderRequestEntity renderRequest = new RenderRequestEntity();
InputSettings inputSettings = new InputSettings();
Template template = new Template();
template.setWorkspace("Default");
template.setPath("Retail/Bookstore Invoice/Invoice.epr");
inputSettings.setTemplate(template);
renderRequest.setInputSettings(inputSettings);
Input input = new Input();
input.setInputFormat("xml");
input.setSource("<?xml version=\"1.0\" standalone=\"yes\"?>" +
"<root>" +
"<Invoices>" +
"<Invoice>" +
"<InvoiceProperties>" +
"<number>02116</number>" +
"<date>2016-06-10</date>" +
"</InvoiceProperties>" +
"<CustomerInformation>" +
"<name>Earl Library Co.</name>" +
"<address>1021 South Main Street, Seattle, Washington 92315</address>" +
"<email>sales@earlbook.com</email>" +
"<telephone>(206)321-2345</telephone>" +
"</CustomerInformation>" +
"<Products>" +
"<Product>" +
"<id>1</id>" +
"<name>Rendezvous with Rama by Arthur C. Clarke</name>" +
"<price>15</price>" +
"<quantity>3</quantity>" +
"<total>45</total>" +
"<description>An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.</description>" +
"</Product>" +
"</Products>" +
"<Comments>" +
"<comments>Contact us with any questions you may have.</comments>" +
"</Comments>" +
"</Invoice>" +
"</Invoices>" +
"</root>");
renderRequest.setInput(input);
renderRequest.setPdfOutput(new PdfOutput());
DirectRenderService renderSvc = new DirectRenderService(eosUrl);
// Send the Request
java.io.InputStream response = renderSvc.render(sessionToken, renderRequest);
// Download the PDF locally
FileOutputStream outputFile = new FileOutputStream(downloadFolder + fileName);
byte[] buffer = new byte[1024];
int bytesRead = -1;
java.io.BufferedInputStream bufferedReader = new java.io.BufferedInputStream(response);
while ((bytesRead = bufferedReader.read(buffer, 0, 1024)) != -1)
outputFile.write(buffer, 0, bytesRead);
response.close();
outputFile.close();
System.out.format("File %s downloaded ok%n", downloadFolder + fileName);
Note
The API Reference entities and methods uses a simplified model. You will need to use setters and getters when working with entities, just like it is used in the above example.
General Notes
This section will cover the common errors encountered when using the REST APIs, along with some information about each of them and the accepted time standards.
Error handling
Each API method can throw error and attempts to return appropriate HTTP status codes. Additional info is included in the body of the response, JSON-formatted.
Example:
//400 BadRequest
{
"Message": "Required parameter 'Path' not found."
}
| Code | Text | Description |
|---|---|---|
| 200 | OK | Success! |
| 201 | Created | Resource created. Usually, the response body represents the newly created resource. |
| 204 | No Content | Request processed. Response is intentionally blank e.g. DELETE operations. |
| 400 | Bad Request | The request was invalid or cannot be otherwise served. An accompanying error message will explain further. |
| 401 | Unauthorized | Missing or incorrect credentials. |
| 403 | Forbidden | The request is understood, but it has been refused or access is not allowed. An accompanying error message will explain why. This is usually because of the current authenticated user not having permission to manage the resource. |
| 404 | Not Found | The URI requested is invalid or the resource requested, such as a user, does not exist. |
| 410 | Gone | This resource is gone. Used to indicate that an API endpoint has been turned off. |
| 415 | Unsupported Media Type | The payload is in a format not supported by this method on the target resource. The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly. |
| 500 | Internal Server Error | Something is broken. Additional explanation is included in the response body. |
Dates and durations
This section helps you pay attention when work with date and time and what these parameters do by the time they leave your API platform. MHC Create solution is to use ISO standards for the time representation.
All dates in the API are strings in the ISO 8601 DateTime format:
"2017-01-26T11:29:35Z"
All durations in the API are string in the ISO 8601 Duration format:
"PT1.52S"
API Reference
This Enteprise API reference is organized by services and resource type. Each service groups similar resources together and has one or more methods that changes these resources (create, read, update, delete, etc.). All HTTP routes are relative to Enterprise Website base URI, e.g. api/v2/token refers to https://eos4.ecrion.com/api/v2/token.
Authorization
In order to make calls to our REST methods, you will need to provide a token authenticating your current user. This call uses a basic authentication with your username and password for generating an authorization key that is your token.
GetToken
Generates the access token used for all API calls.
GET /api/v2/token
To generate an access token, call this method and supply the user credentials (case sensitive). The preferred way of authenticating is to use an API key. For more information about API keys, see Authentication.
The response contains an access token that needs to be passed via Authorization header using Basic <sessionTokenInbase64> format in order to authorize a generic endpoint.
If you're using our JavaScript, .NET or Java client API this process is simplified (examples below).
Parameters
Authorization- Authorization credentials:<apiKey>
Returns TokenEntity
AccessToken- Access token ofstringtype that can be used in Authorization headers.
Examples
JavaScript
If you're running JavaScript inside a browser, you should avoid typing the credentials in plain text because the .js sources are available to the client.
Instead, it is preferred to store the API Key on your server and do the authentication in a secure backend, passing only a sessionToken to the client, using authorizeWithToken utility.
eosAPI.ready(function(){
var sessionToken = obtainTokenFromMyBackend();
eosAPI.authorizeWithToken(sessionToken);
//all subsequent eosAPI calls will use the sessionToken
})
However, if you're using JavaScript in a server-side environment or the credentials are provided by the client user, the authorize utility method is available.
Internally, it calls Auth.GetToken and uses the returned access token for all subsequent calls through the eosAPI global instance:
var apiKey = "API:dee401eb-d3e5-4523-9f90-c19a573e7e0a";
eosAPI.authorize(apiKey)
.catch(function(response){
// Handle any authentication errors here
alert("Authentication failure: " + err.statusText);
});
eosAPI.authorized(function(){
//all eosAPI calls will use the sessionToken obtained based on the apiKey
});
The authorize method supports passing two arguments, i.e. eosAPI.authorize(username, password) if you want to use a username/password combination.
If credentials are used on multiple environments, the environment name is required
For example → eosAPI.authorize(username, password, environment).
.NET
string apiKey = "API:dee401eb-d3e5-4523-9f90-c19a573e7e0a";
AuthorizationService authSvc = new AuthorizationService("https://eos4.ecrion.com/");
string sessionToken = authSvc.GetToken(apiKey).AccessToken;
Alternatively, it's possible to use a username/password combination to authenticate.
For example → authSvc.GetToken(username + ":" + password)
If credentials are used on multiple environments, the environment name is required to authenticate.
For example → authSvc.GetToken(environment + "#" + username + ":" + password)
Java
String apiKey = "API:dee401eb-d3e5-4523-9f90-c19a573e7e0a";
AuthorizationService authSvc = new AuthorizationService("https://eos4.ecrion.com/");
String sessionToken = authSvc.getToken(apiKey);
Alternatively, it's possible to use a username/password combination to authenticate:
For example → authSvc.getToken(username + ":" + password)
If credentials are used on multiple environments, the environment name is required to authenticate:
For example → authSvc.GetToken(environment + "#" + username + ":" + password)
HTTP
curl -X GET --header "Accept: application/json" --header "Authorization: Basic QVBJOjBhZTRhZjQxLWI1MzAtNDAzOC1iZTgyLWEwZmE4YjNmMWQ1NQ==" "http://localhost:50100/api/v2/token"
Alternatively, it's possible to use a username/password combination to authenticate. Replace -u apiKey: with -u username:password
If credentials are used on multiple environments, the environment name is required to authenticate. Replace -u apiKey: with -u environment#username:password
Repository
MHC Create Repository stores all assets involved in document production (images, templates, stylesheets, etc.) in a file repository. The Create core-only installation provides a basic level of functionality.
Methods:
- Repository.DownloadFile
- Repository.UploadFile
- Repository.GetFiles
- Repository.UpdateFile
- Repository.DeleteFile
- Repository.ExportFolder
- Repository.ImportFolder
- Repository.CreateFolder
- Repository.GetFolders
- Repository.DeleteFolder
Entities:
DownloadFile
Download a file from Create repository.
GET /api/v2/files/content
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name Requiredpath- File path Required
Returns
binary data- File bytes
Examples
JavaScript
eosAPI.Repository.DownloadFile({
workspace: "Default",
path: "Retail/Bookstore Invoice/Main.wk4"
})
.then(function(response) {
var content = response.data;
})
.NET
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
Stream content = repo.DownloadFile(token, "Default", "Retail/Bookstore Invoice/Main.wk4");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
java.io.InputStream content = repo.downloadFile(token, "Default", "Retail/Bookstore Invoice/Main.wk4");
HTTP
curl -u "TOKEN:7a6961b5-5be4-4318-b82e-4631659efa38" "https://eos4.ecrion.com/api/v2/files/content?workspace=Default&path=Retail/Bookstore%20Invoice/Main.wk4"
__
UploadFile
Upload a file to Create repository.
POST /api/v2/files/content
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- File path. Requiredfile- The file to upload. Required
Returns
Examples
JavaScript
eosAPI.Repository.UploadFile({
workspace: "Default",
path: "Retail/Bookstore Invoice/Sample.xml",
file: new File(['<?xml version=\"1.0\" standalone=\"yes\"?><root></root>'], "Sample.xml", {type: "text/xml"})
})
.then(function(response) {
var file = response.obj;
});
.NET
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
using (FileStream fsSource = new FileStream(@"C:\Sample.xml", FileMode.Open, FileAccess.Read))
{
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
FileEntity fileResponse = repo.UploadFile(token, "Default", "Retail/Bookstore Invoice/Sample.xml", fsSource);
}
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
java.io.InputStream fsSource = new FileInputStream("C:\\Sample.xml");
repo.uploadFile(token, "Default", "Retail/Bookstore Invoice/Sample.xml", fsSource);
HTTP
curl -X POST -F "file=@C:\Sample.xml" -u "TOKEN:7a6961b5-5be4-4318-b82e-4631659efa38" "https://eos4.ecrion.com/api/v2/files/content?workspace=Default&path=Retail/Bookstore%20Invoice/Sample.xml"
__
GetFiles
Returns a list of files from the Create repository.
GET /api/v2/files
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Path to the folder containing the files or a file path1. Requiredfields- A comma separated list of additional fields to be included.- Allowed Values:
tags - Default:
null
- Allowed Values:
start- Start index- Default:
0
- Default:
count- Number of results- Default:
Int32.MaxValue
- Default:
Notes
1. If the path is a file the result will contain a list of one file metadata from the specified file path.
2. To search files after a tag you need to specify both tagName and tagValue.
Returns FileEntity[] - A list of FileEntity
Path- Path to the fileWorkspace- The workspace name in which the file is locatedAuthor- The name of the author of the current versionCreatedDate- The date when the current version was created (see Date Format)Type- A friendly file type name (e.g."PDF File")Bytes- The file size in bytesSize- A human-readable description of the file sizeTags- List ofTagEntityfile tags IF asked for. Otherwise it'snullName- Name of the tagValue- Value of the tag
Version- The 1-based version index
Examples
JavaScript
// List all files in Bookstore Invoice folder
eosAPI.Repository.GetFiles({
workspace: "Default",
path: "Retail/Bookstore Invoice"
})
.then(function(response) {
var files = response.obj;
})
.NET
// List all files in Bookstore Invoice folder
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
List<FileEntity> files = repo.GetFiles(token, "Default", "Retail/Bookstore Invoice");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
java.util.List<FileEntity> files = repo.getFiles(token, "Default", "Retail/Bookstore Invoice", null, 0, 10, null, null);
HTTP
curl -u "TOKEN:7a6961b5-5be4-4318-b82e-4631659efa38" "https://eos4.ecrion.com/api/v2/files?workspace=Default&path=Retail/Bookstore%20Invoice"
__
UpdateFile
Rename, copy or move a file.
PUT /api/v2/files
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Path to the file on which to perform the action. RequiredfileOperation- of typeFileOperationEntity. RequiredPath- The new file path. RequiredAction- The action to perform on file. Can berename,copyormove. RequiredOverwrite- Specifies how to resolve the conflict if the new file path exists- Allowed values:
true,false - Default:
false
- Allowed values:
Returns
204 (No Content)- HTTP status code
Examples
JavaScript
eosAPI.Repository.UpdateFile({
workspace: "Default",
path: "/Design/Invoice/Invoice.epr",
fileOperation:{
path: "/Design/Invoice/Invoice2.epr",
action: "copy"
}
})
.then(function(response) {
var status = response.status;
});
.NET
//duplicate Invoice.epr as Invoice2.epr
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
repo.UpdateFile(token, "Default", "Retail/Bookstore Invoice/Invoice.epr",
new FileOperationEntity()
{
Path = "Retail/Bookstore Invoice/Invoice2.epr",
Action = "copy"
});
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
FileOperationEntity op = new FileOperationEntity();
op.setPath("Retail/Bookstore Invoice/Invoice2.epr");
op.setAction("copy");
op.setOverwrite(true);
repo.updateFile(token, "Default", "Retail/Bookstore Invoice/Invoice.epr", op);
HTTP
curl -H "Content-Type: application/json" -X PUT -d "{ 'Path':'Retail/Bookstore Invoice/Invoice2.epr', Action:'copy' }" -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80:" "https://eos4.ecrion.com/api/v2/files?workspace=Default&path=Retail/Bookstore%20Invoice/Invoice.epr"
__
DeleteFile
Delete a file from Create repository.
DELETE /api/v2/files
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name Requiredpath- The path of the file to be deleted Required
Returns
204 (No Content)- HTTP status code
Examples
JavaScript
eosAPI.Repository.DeleteFile({
workspace: "Default",
path: "Retail/Bookstore Invoice/Main.wk4",
})
.then(function(response) {
var status = response.status;
});
.NET
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
repo.DeleteFile(token, "Default", "Retail/Bookstore Invoice/Main.wk4");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
repo.deleteFile(token, "Default", "Retail/Bookstore Invoice/Main.wk4");
HTTP
curl -X DELETE -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80:" "https://eos4.ecrion.com/api/v2/files?workspace=Default&path=Retail/Bookstore%20Invoice/Main.wk4"
__
ExportFolder
Download a zip file of a folder from Create repository.
GET /api/v2/folders/content
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Path to the folder to be exported. Required
Returns
binary data- the zip file
Examples
JavaScript
eosAPI.Repository.ExportFolder({
workspace: "Default",
path: "Retail/Bookstore Invoice"
})
.then(function(response) {
// zip is a blob
var zip = response.data;
});
.NET
// Export Bookstore Invoice folder
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
Stream zip = repo.ExportFolder(token, "Default", "Retail/Bookstore Invoice");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
java.io.InputStream zip = repo.exportFolder(token, "Default", "Retail/Bookstore Invoice");
HTTP
curl -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80:" "https://eos4.ecrion.com/api/v2/folders/content?workspace=Default&path=Retail/Bookstore%20Invoice"
__
ImportFolder
Decompress an archive and uploads its content to Create repository.
POST /api/v2/folders/content
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Folder path. Requiredfile- Zip file bytes. Required
Returns
Examples
JavaScript
//Upload generated .zip file
eosAPI.Repository.ImportFolder({
workspace: "Default",
path: "Retail/Bookstore Invoice",
file: new File([/*content*/ ], "myFolder.zip")
})
.then(function(response) {
var folder = response.obj;
})
.NET
// Import 'myFolder' to Bookstore Invoice folder
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
using (FileStream fsSource = new FileStream(@"C:\myFolder.zip", FileMode.Open, FileAccess.Read))
{
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
FolderEntity folder = repo.ImportFolder(token, "Default", "Retail/Bookstore Invoice", false, fsSource);
}
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
java.io.InputStream fsSource = new FileInputStream("C:\\myFolder.zip");
repo.importFolder(token, "Default", "Retail/Bookstore Invoice", false, fsSource);
HTTP
curl -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80:" -F filedata=@"C:\myFolder.zip" "http://eos4.ecrion.com/api/v2/folders/content?workspace=Default&path=Retail/Bookstore%20Invoice"
__
CreateFolder
Create a new folder.
POST /api/v2/folders
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Folder path. Required
Returns FolderEntity
Path- Path to the folderWorkspace- Workspace name in which the folder is locatedCreatedDate- Date when the folder was created (see Date Format)FilesCount- Total number of files inside the folder (non recursive)FoldersCount- Total number of folders inside the folder (non recursive)
Examples
JavaScript
eosAPI.Repository.CreateFolder({
workspace: "Default",
path: "NewFolder"
})
.then(function(response) {
var folder = response.obj;
})
.NET
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
FolderEntity folder = repo.CreateFolder(token, "Default", "NewFolder");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
FolderEntity folder = repo.createFolder(token, "Default", "NewFolder");
HTTP
curl -X POST -d "{'path' : 'NewFolder'}" -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80" "https://eos4.ecrion.com/api/v2/folders?workspace=Default&path=NewFolder"
__
GetFolders
Returns a list of folders in the specified parent path and workspace.
GET /api/v2/folders
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Folder path. Requiredstart- Start indexcount- Number of results
Returns
FolderEntity[]- A list of FolderEntity
Examples
JavaScript
// List all folders from a workspace
eosAPI.Repository.GetFolders({
workspace: "Default",
path: "Retail/Bookstore Invoice"
})
.then(function(response) {
var folders = response.obj;
})
.NET
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
List<FolderEntity> folders = repo.GetFolders(token, "Default", "Retail/Bookstore Invoice");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
java.util.List<FolderEntity> folders = repo.getFolders(token, "Default", "Retail/Bookstore Invoice", 0, 10);
HTTP
curl -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80" "https://eos4.ecrion.com/api/v2/folders?workspace=Default&path=Retail/Bookstore%20Invoice"
__
DeleteFolder
Delete an existing folder.
DELETE /api/v2/folders
Parameters
Authorization- Override the Authorization header value.workspace- Workspace name. Requiredpath- Folder path. Required
Returns
204 (No Content)- HTTP status code
Examples
JavaScript
eosAPI.Repository.DeleteFolder({
workspace: "Default",
path: "Retail/Bookstore Invoice"
})
.then(function(response) {
var status = response.status;
})
.NET
string token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
repo.DeleteFolder(token, "Default", "Retail/Bookstore Invoice");
Java
String token = "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80";
RepositoryService repo = new RepositoryService("https://eos4.ecrion.com/");
repo.deleteFolder(token, "Default", "Retail/Bookstore Invoice");
HTTP
curl -X DELETE -u "TOKEN:c87ca566-2587-4480-8a7a-27531f04af80" "https://eos4.ecrion.com/api/v2/folders?workspace=Default&path=Retail/Bookstore%20Invoice"
DirectRender
The Render API call allows you to configure what type of output you would like to produce, what template to use and other variables that will drive this to production. In this section, you will have access to the different configuration options for each output type.
Render
Render input into a variety of output formats including PDF, Word, etc.
POST /api/v2/render
Parameters
Authorization-
requestof typeRenderRequestEntityInput- You can specify either aSourceor a combination of anWorkspaceandPath. RequiredInputFormat- Format of the source document- Allowed Values:
pdf,xslfo,svg,xml,wordml,docx,html,eps,dal,das,xfd,excel,json
- Allowed Values:
Source- String representing the source document. Use BASE64 encoding if the source document is binary.Workspace- The workspace namePath- The file path
InputSettingsReferenceResolver- Specifies the reference resolver behavior. The reference resolver is a separate pre-processing step which solves dynamic fields which are layout-dependent, e.g. page numbers, indexes. It can be set to run before starting to produce pages, in parallel with producing pages, or not at all (in which case some fields may not appear in the document). By default, it will use parallel if available (based on your license) or serial if not.- Allowed Values:
parallel,serial,disabled - Default:
parallel
- Allowed Values:
FontErrors- Specifies what to do when a font is not found. By default, it will use the default font, but it can also be set to throw an error.ImageErrors- Specifies what to do when an image is not found or cannot be processed. By default, it will use a stock image, but it can also be set to throw an error or ignore the missing element and not render any placeholder.- Allowed Values:
usestock,throw,ignore - Default:
usestock
- Allowed Values:
TemplateInputBytesID(string, optional) - Helps correlate the request sent to the render in the log file. The value can be any string (e.g. a GUID); afterward you can search for it in the EngageCX logs.
TemplateWorkspace- The workspace namePath- The file pathLanguageId- Language idPreserveWhitespace- Specifies if whitespace is preserved in the template.- Allowed Values:
Yes,No
- Allowed Values:
XSLTEngine- The XSL Transformation EngineMSXML- A very fast XSL 1.0 engine; support for JavaScript.DotNet20- An XSL Engine used to create compiled XSLT Templates.Saxon- An XSL Engine best for low memory consumption; support for XSL 1.0 and XSL 2.0. No support for Java
TemplateParameters- A key-value mapping that sets template parameters.Name- Template parameter nameValue- Template parameter value
HtmlInput- HTML input settingsEncoding- Specifies the character encoding of the input HTML document- Allowed Values:
utf8,win1252
- Allowed Values:
PageWidth- Specifies the page width as a length value or automatic.- Default:
auto
- Default:
PageHeight- Specifies the page height as a length value or automatic.- Default:
auto
- Default:
PageMarginTop- Specifies the page top margin as a length value.- Default:
1in
- Default:
PageMarginLeft- Specifies the page left margin as a length value.- Default:
1in
- Default:
PageMarginRight- Specifies the page right margin as a length value.- Default:
1in
- Default:
PageMarginBottom- Specifies the page bottom margin as a length value.- Default:
1in
- Default:
PageHeaderMargin- Specifies the page header margin as a length value.- Default:
0.5in
- Default:
PageFooterMargin- Specifies the page footer margin as a length value.- Default:
0.5in
- Default:
ShowPageNumber- Specifies whether to render page numbers in the output.ShowTitle- Specifies whether to render page title in the output.
PdfOutput- Default output if none specified.PrefixFontSubset- Specifies whether to add prefixes to the names of subsetted fonts in the internal structure of the output PDF.EmbedTTF- Specifies whether to embed TrueType fonts.HideToolbar- Specifies whether to hide the PDF viewer menubar.HideMenubar- Specifies whether to hide the PDF viewer menubar.HideWindowUI- Specifies whether to hide the PDF viewer window UI.FitWindow- Specifies whether the output PDF should fit the window when opened.CenterWindow- Specifies whether the output PDF should center in the window when opened.DisplayDocTitle- Specifies whether to display the title of the output PDF.Conformance- Specifies the level of PDF conformance.- Allowed Values:
none,pdfx,pdfa-1a,pdfa-1a-accesible,pdfa-1b,pdf508,pdfx4p,pdfx4,pdfwcag2.0,pdfwcag2.1
- Allowed Values:
Version- Specifies the PDF version.- Allowed Values:
pdf16,pdf14,pdf15,pdf17 - Default:
pdf16
- Allowed Values:
AllowPrinting- If owner-password is set, this can be set to allow printing.AllowModifyContents- If owner-password is set, this can be set to allow editing.AllowCopy- If owner-password is set, this can be set to allow copying.AllowModifyAnnotations- If owner-password is set, this can be set to allow manipulating annotations.AllowFillIn- If owner-password is set, this can be set to allow filling in forms.AllowScreenReaders- If owner-password is set, this can be set to allow screen readers.AllowAssembly- If owner-password is set, this can be set to allow document assembly.AllowDegradedPrinting- If owner-password is set, this can be set to allow degraded printing.ImageCompression- Specifies the type of image compression.- Allowed Values:
jpeg,flat - Default:
jpeg
- Allowed Values:
OwnerPassword- Set an owner password to a string value. This presents the user with a prompt to enter the password when attempting to edit the document. It is used in conjunction with the encryption-strength field and the allow-* fields to encrypt the document bytes and enable granular permissions on the document (although the password can be read from the document to decrypt the contents).UserPassword- Set a user password to a string value. This presents the user with a prompt to enter the password when opening the document. It is used in conjunction with the encryption-strength field to encrypt the document bytes.PDFMergeFonts- Specify the way fonts are generated in the final output. It is useful to reduce the size of the output when merging PDFs.- Allowed Values:
true- set the font to be embedded,false- set the font to not be embedded (it is based on the System Fonts from Windows),empty- takes the font value from the configuration file.
- Allowed Values:
EncryptionsStrength- If a password is set, specifies the strength with which to encrypt the document.- Allowed Values:
48,128 - Default:
48
- Allowed Values:
-
HtmlOutput- Default output if none specified.HideStaticContent- Skip rendering of static content elements (headers, footers, etc.) in HTML output.GenerateHtmlDocument- Specifies whether to wrap the generated HTML content to form a full HTML document, i.e. html, head, and body tags.UseFixedBodyWidth- Specifies whether to use a fixed width to approximate a paginated document layout or a fluid layout based on the window size.RenderedImagesBaseUrl- Specifies where to look for images and other resources linked with relative paths. All relative paths will be resolved relative to this URL. While not required, it is recommended for consistency. Defaults to the current directory.InteractiveWidgets- Specifies whether to render BI widgets as interactive or static.RenderedImagesOutputFolder- Specifies the output folder for the rendered images.EmbedImageMode- specifies how an image should be embedded in an HTML output.- Allowed Values:
base64- Embeds images as base64 in html output,cid- Makes zip with html and images,preserveurl- If the input contains http/https referenced image it will preserve the URL in HTML output. **Note: The image that is embedded in base64 will remain embedded. ** - Default:
base64
- Allowed Values:
Note
HTML output in MHC Create can be used to generate content for web browsers (Firefox, Safari, Chrome, Edge, etc.) However, it is not suitable to be sent via email.
-
TxtOutput- Text Output that exports data to a text fileEncoding- Specifies the output file encoding.- Allowed Values:
utf-8,utf-16,ascii - Default:
ascii
- Allowed Values:
FormFeed- Specifies whether to separate pages using the form feed character.IgnoreCssBoxAttributes- Specifies whether to ignore CSS box attributes or perform layout on the document, spacing out the text vertically and horizontally in order to approximate the original layout.TrimPages- Specifies whether to trim whitespace off pages.LineHeight- Specifies the value in points to assume as the output's line height.- Default:
1.4
- Default:
FontSize- Specifies the value in points to assume as the output's font size.- Default:
9
- Default:
FontFamily- Specifies the font family to assume will be used in the output.- Default:
Courier New
- Default:
Returns
binary data- the output document, in a format determined by the request output settings.- The response header will return back the render statistics
x-render-stats-page-count- shows the page count of the generated documentx-render-input-bytes-id- returns the InputBytesID from the request, if specified
Page Count
Returns the page count of the result of a render task.
POST /api/v2/pagecount
Parameters
Examples
JavaScript
eosAPI.DirectRender.Render({
request: {
InputSettings: {
Template: {
Workspace: "Default",
Path: "Retail/Bookstore Invoice/Invoice.epr"
}
},
Input: {
InputFormat: "xml",
Source: "<?xml version=\"1.0\" standalone=\"yes\"?><root><Invoices><Invoice><InvoiceProperties><number>02116</number><date>2016-06-10</date></InvoiceProperties><CustomerInformation><name>Earl Library Co.</name><address>1021 South Main Street, Seattle, Washington 92315</address><email>sales@earlbook.com</email><telephone>(206)321-2345</telephone></CustomerInformation><Products><Product><id>1</id><name>Rendezvous with Rama by Arthur C. Clarke</name><price>15</price><quantity>3</quantity><total>45</total><description>An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.</description></Product></Products><Comments><comments>Contact us with any questions you may have.</comments></Comments></Invoice></Invoices></root>"
},
TxtOutput: {}
}
})
.then(function(response) {
var content = response.data;
})
.NET
DirectRenderService renderSvc = new DirectRenderService("https://eos4.ecrion.com/");
// Create a new request
RenderRequestEntity request = new RenderRequestEntity();
request.InputSettings = new InputSettings();
request.InputSettings.Template = new Template();
request.InputSettings.Template.Workspace = "Default";
request.InputSettings.Template.Path = "Retail/Bookstore Invoice/Invoice.epr";
request.Input = new Input();
request.Input.InputFormat = "xml";
request.Input.Source = "<?xml version=\"1.0\" standalone=\"yes\"?><root><Invoices><Invoice><InvoiceProperties><number>02116</number><date>2016-06-10</date></InvoiceProperties><CustomerInformation><name>Earl Library Co.</name><address>1021 South Main Street, Seattle, Washington 92315</address><email>sales@earlbook.com</email><telephone>(206)321-2345</telephone></CustomerInformation><Products><Product><id>1</id><name>Rendezvous with Rama by Arthur C. Clarke</name><price>15</price><quantity>3</quantity><total>45</total><description>An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.</description></Product></Products><Comments><comments>Contact us with any questions you may have.</comments></Comments></Invoice></Invoices></root>";
request.TxtOutput = new TxtOutput();
// Send the request
Stream content = renderSvc.Render(sessionToken, request);
Java
DirectRenderService renderSvc = new DirectRenderService("https://eos4.ecrion.com/");
// Create a new request
RenderRequestEntity request = new RenderRequestEntity();
InputSettings inputSettings = new InputSettings();
Template template = new Template();
template.setWorkspace("Default");
template.setPath("Retail/Bookstore Invoice/Invoice.epr");
inputSettings.setTemplate(template);
request.setInputSettings(inputSettings);
Input input = new Input();
input.setInputFormat("xml");
input.setSource("<?xml version=\"1.0\" standalone=\"yes\"?><root><Invoices><Invoice><InvoiceProperties><number>02116</number><date>2016-06-10</date></InvoiceProperties><CustomerInformation><name>Earl Library Co.</name><address>1021 South Main Street, Seattle, Washington 92315</address><email>sales@earlbook.com</email><telephone>(206)321-2345</telephone></CustomerInformation><Products><Product><id>1</id><name>Rendezvous with Rama by Arthur C. Clarke</name><price>15</price><quantity>3</quantity><total>45</total><description>An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.</description></Product></Products><Comments><comments>Contact us with any questions you may have.</comments></Comments></Invoice></Invoices></root>");
request.setInput(input);
request.setTxtOutput(new TxtOutput());
// Send the request
java.io.InputStream response = renderSvc.render(sessionToken, request);
HTTP
curl -H "Content-Type: application/json" -X POST -u "TOKEN:7a6961b5-5be4-4318-b82e-4631659efa38" -d "{ 'Input' : { 'Source' : '<?xml version=\"1.0\" standalone=\"yes\"?><root></root>' }, 'InputSettings' : { 'Template' : { 'Workspace' : 'Default', 'Path' : 'Retail/Bookstore Invoice/Invoice.epr' } }, 'TxtOutput' : {}}" "http://localhost:50100/api/v2/render"
DirectData
The Direct Data API call uses diagrams as inputs, built in Modeler and ingest data, for example, directly as batches.
Data
Process a data model diagram and return the output data as a stream.
POST /api/v2/data
Parameters
AuthorizationRequireddataRequestof typeDataRequestEntityInputSettingsof typeDataInputSettingsDiagramWorkspace- The workspace namePath- The file pathDiagramParameters- A list with string triplets that can be used to overwrite some attributes in the data processing such as a connection string, parameter value, etc.Id- Specifies the id of the XML element on which this property should be applied.Name- Specifies the name of the property (e.g. XML attribute name).Value- Specifies the new value for the attribute that will be overwritten.
Returns
binary data- the output data stream, in a format determined by the input diagram.
Notes
If the diagram format is .edx , then the output will be an XML File.
If the diagram format is .edm, then the output will be an IMDB File.
If the diagram format is .edo, then the output will be a Data Operations Output file.
If the diagram format is .ede, then the output will be an Excel Output file.
Examples
JavaScript
eosAPI.DirectData.Data({
request: {
InputSettings: {
Diagram: {
Workspace: "Default",
Path: "Retail/Bookstore Invoice/Invoice.edx"
}
}
}
})
.then(function(response) {
var content = response.data;
})
.NET
DirectDataService dataSvc = new DirectDataService("https://eos4.ecrion.com/");
// Create a new request
DataRequestEntity request = new DataRequestEntity();
request.InputSettings = new DataInputSettings();
request.InputSettings.Diagram = new Diagram();
request.InputSettings.Diagram.Workspace = "Default";
request.InputSettings.Diagram.Path = "Retail/Bookstore Invoice/Invoice.edx";
// Send the request
Stream content = dataSvc.Data(sessionToken, request);
Java
DirectDataService dataSvc = new DirectDataService("https://eos4.ecrion.com/");
// Create a new request
DataRequestEntity request = new DataRequestEntity();
DataInputSettings inputSettings = new DataInputSettings ();
Diagram diagram = new Diagram ();
diagram.setWorkspace("Default");
diagram.setPath("Retail/Bookstore Invoice/Invoice.edx");
inputSettings.setTemplate(template);
request.setInputSettings(inputSettings);
// Send the request
java.io.InputStream response = dataSvc.data(sessionToken, request);
HTTP
curl -H "Content-Type: application/json" -X POST -d "{ 'InputSettings' : { 'Diagram' : { 'Workspace' : 'Default', 'Path' : 'Retail/Bookstore Invoice/Invoice.edx' } }" -u "TOKEN:83b02efa-9253-413e-896b-d1011e5127fc" "https://eos4.ecrion.com/api/v2/data"
Status
The Status API call uses the status of a HTTP response message to inform users about the server.
GetStatus
Get information about the server: Name, Version, Build number and Status.
GET /api/v2/status
Returns StatusEntity
ProductName- Name of the installed solutionProductVersion- The current version of the installed solutionBuildNumber- The build number of the current versionStatusCode- The code of the server statusStatus Description- The description of the server status
Examples
JavaScript
eosAPI.Server.GetStatus({
url: "http://eos4.ecrion.com",
})
.then(function(response) {
var content = response.data;
})
.NET
ServerService server = new ServerService("https://eos4.ecrion.com/");
StatusEntity statusResponse = server.getStatus();
Java
ServerService server = new ServerService("https://eos4.ecrion.com/");
java.util.List<StatusEntity> statuses = server.getStatus();
HTTP
curl -X GET --header "Accept: application/json" --header "Authorization: Basic MGFlNGFmNDEtYjUzMC00MDM4LWJlODItYTBmYThiM2YxZDU1" "http://localhost:50100/api/v2/status"