Retrieving Content¶
The TrustID Cloud provides mechanisms to retrieve individual content data such as applications, individual documents, or images.
Retrieving Applications¶
Individual applications can be retrieved separately as shown below:
Request
POST {{server}}/VPE/dataAccess/retrieveDocumentContainer/
Content-Type: application/json
{
"DeviceId": "device-id",
"SessionId": "...",
"ContainerId": "..."
}
For details, see the /dataAccess/retrieveDocumentContainer/ endpoint.
Response
This contains the actual data of the document container through the
DocumentContainerResponse.Container
property.
{
"Success": true,
"Message": "Operation executed successfully.",
"Container": {
...
}
}
The property RetrieveDocumentContainerRequest.ContainerId
is the
unique identifier of the document container retrieved through this endpoint.
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// create a new (empty) container
return api.createEmptyDocumentContainer(Container.DOCUMENT_SOURCE_IMAGE).then
(function(containerResponse) {
var containerId = containerResponse.ContainerId;
api.createDocument(containerId).then(function(response) {
return api.publishDocumentContainer(containerId);
}).then(function(response) {
return api.retrieveDocumentContainer(containerId);
}).then(function(application) {
console.log('retrieved application:', application);
});
});
});
For details, see Api.retrieveDocumentContainer.
Note
Document containers can be retrieved if the application has been archived. Applications cannot be retrieved while they are being constructed and before they are published.
The current user must have permission to retrieve the application.
Retrieving Documents¶
When a document container is retrieved, all data is self-contained within the application response message, including all the application’s documents. However, if required, individual documents can be retrieved separately as shown below:
Request
POST {{server}}/VPE/dataAccess/retrieveDocument/
Content-Type: application/json
{
"DeviceId": "device-id",
"SessionId": "...",
"ContainerId": "...",
"DocumentId": "..."
}
Response
{
"Success": true,
"Message": "Operation executed successfully.",
"Document": {
...
}
}
For endpoint details, see /dataAccess/retrieveDocument/.
The response contains the actual data of the document through the
DocumentResponse.Document
property.
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// create a new (empty) container
return api.createEmptyDocumentContainer(Container.DOCUMENT_SOURCE_IMAGE).then
(function(containerResponse) {
var containerId = containerResponse.ContainerId;
api.createDocument(containerId).then(function(documentResponse) {
var documentId = documentResponse.DocumentId;
api.publishDocumentContainer(containerId).then(function(response) {
return api.retrieveDocument(containerId, documentId);
}).then(function(document) {
console.log('retrieved document:', document);
});
});
});
});
For details, see Api.retrieveDocument.
Note
Individual documents can be retrieved if the corresponding application has been archived. Documents cannot be retrieved while they are being constructed and the corresponding application has not been published.
The current user must have permission to retrieve the document.
Retrieving Image Data¶
There are two ways to retrieve the actual data of a document image.
Method 1
Request
POST {{server}}/VPE/dataAccess/retrieveImage/
Content-Type: application/json
{
"DeviceId": "device-id",
"SessionId": "...",
"ImageId": "..."
}
For endpoint details, see /dataAccess/retrieveImage/.
The only argument required for this endpoint is the unique identifier of the image. The response is a data stream representing the binary image data.
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// retrieve document container for the given containerId(guid)...
return api.retrieveDocumentContainer(containerId);
}).then(function(application) {
var doc = applications.Documents[0];
var img = doc.Images[0];
// retrieve image binary data
api.retrieveImage(img.Id).then(function(imageData) {
console.log('image data:', imageData.length, 'bytes');
});
});
For details, see Api.retrieveImage.
Method 2
Here the image is received by using a simple GET
request that makes it possible to embed the resulting URL using an HTML IMG
tag:
Request:
<img src="{{server}}/VPE/dataAccess/image/?id=...&DeviceId=...&SessionId=..." alt="">
For details see /dataAccess/image/.
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// retrieve document container for the given containerId(guid)...
return api.retrieveDocumentContainer(containerId);
}).then(function(application) {
var doc = applications[0].Documents[0];
var img = doc.Images[0];
// insert image into DOM
var imageElement = document.createElement('img');
imageElement.src = api.getImageUrl(img.Id);
document.body.appendChild(imageElement);
});
For details, see Api.getImageUrl.
Note
In method 2 security-related properties such as the
device identifier and session identifier may be exposed as GET
arguments. If the connection is over HTTPS
, all headers and GET
arguments are encrypted but GET
arguments may still appear in
the web server log files and/or in the browser history.
If there is an error the response may be an empty data stream.
PDF Report¶
The TrustID Cloud can generate a PDF-based assessment report for an application. This summarises the application and document data.
There are two ways to generate a PDF report for an application.
Method 1
Request
POST {{server}}/VPE/dataAccess/exportPDF/
Content-Type: application/json
{
"DeviceId": "device-id",
"SessionId": "...",
"ContainerId": "..."
}
For endpoint details, see /dataAccess/exportPDF/.
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// retrieve pdf binary data for the given containerId(guid)...
api.exportPdf(containerId).then(function(pdfData) {
console.log('pdf data:', pdfData.length, 'bytes');
});
});
The response is a binary data stream that represents a PDF file.
Method 2
A PDF report can be downloaded directly by using a simple
GET
request with the /dataAccess/downloadPDF/
endpoint. This endpoint makes it possible to embed a download link within an HTML document, for example:
Download link:
<a href="{{server}}/VPE/dataAccess/downloadPDF/?id=...&DeviceId=...&SessionId=..."download>Download PDF </a>
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// retrieve document container for the given containerId(guid)...
return api.retrieveDocumentContainer(containerId);
}).then(function(application) {
// insert pdf into DOM
var pdfElement = application.createElement('pdf');
imageElement.src = api.getPdfUrl(application.Id);
application.body.appendChild(pdfElement);
});
Note
In method 2 security-related properties such as the
device identifier and session identifier may be exposed as GET
arguments. If the connection is over HTTPS
, all headers and GET
arguments are encrypted but GET
arguments may still appear in log files
of the web server and/or in the history of the browser.
The response may be an empty data stream if there is an error condition.
Retrieving Branches¶
Each user of the TrustID system is allocated to a branch. Obtain a list of all branches configured on the system as shown below.
This may be useful if you are submitting queued applications, or you need to search for applications on a branch basis.
Request
POST {{server}}/VPE/dataAccess/queryBranchesX/
Content-Type: application/json
{
"DeviceId": "device-id",
"SessionId": "..."
}
For endpoint details, see /dataAccess/queryBranchesX/.
var api = new TVS.Api();
api.login('username', 'password').then(function() {
// retrieve Metadata for all visible branches...
api.getBranchesX().then(function(branchList) {
// examine first branch
var branch = branchList[0];
console.log('Branch Name:', branch.Name);
console.log('Branch Id:', branch.Id);
});
});