skip to main content
Corticon Server: Integration & Deployment Guide : Corticon API reference : REST Management API : Common REST request/response Types
 

Try Corticon Now
Common REST request/response Types

Common Request/Response types

Base64 Encoded Files
All JSON embedded files will be encoded into strings using the Base64 Content-Transfer-Encoding as described in RFC 2045 The String will have the following properties:
*The String will NOT be URL safe encoded.
*The string will be on a single line -- in other words, no line separators
The implementation of this particular encoding uses the Java SE DatatypeConvert item to convert to and from Base64 The decoding of the file is done (more or less) using this code (where base64String is the string containing the Base64 encoding):
import javax.xml.bind.DatatypeConverter;
...
String base64String = ...;
...
byte[] base64ByteArray = DatatypeConverter.parseBase64Binary(base64String);
InputStream base64FileInputStream = new ByteArrayInputStream(base64ByteArray);
The encoding of the file should be done using the requirements specified above. Check that the library you use performs proper encoding and decoding the string. The following example shows how to properly encode an array of bytes into a Base64 string using the JavaSE DatatypeConverter (where byteArrayOfBinaryFile is the byte array used to encode using Base64):
import javax.xml.bind.DatatypeConverter;
...
byte[] byteArrayOfBinaryFile = ...;
...
String base64String = DatatypeConverter.printBase64Binary(byteArrayOfBinaryFile);

//Note: This version will chunk the Base64 string into 76 character lines, most implementations do not have problems with this but some will.
Windowed Metrics
Some of the metrics returned by various calls to the API contain windowed metrics. These metrics will be placed in an array of objects, each object will represent a particular section of time. The sections of time for each are differentiated by a "timestamp" field in the object, the value of which is a UTC count of milliseconds. If for some reason a metric is not available for a particular window, its field will not be included in the window object.
Metric Types
Both windowed and non-windowed metrics have specific types associated with them, as follows:
*milliseconds - Stored in JSON as a positive integer value, the value represents a countable number of milliseconds.
*count - Stored in JSON as a positive integer value, the value represents some countable value in the set of integers.
*byte - Stored in JSON as a positive integer value, the value represents a discrete number of bytes. This value is often used to show quantities of used or unused memory.
*string - Stored in JSON as a string, the value represents human readable text.