Welcome to the PlanetPress Connect REST API Cookbook11
Technical Overview12
Workflow & Workflow Processes13
Data Mapping14
Content Creation15
Job Creation16
Output Creation17
All-In-One18
Input Files20
Data Entities21
Data Set & Data Record Entities21
Content Set & Content Item Entities22
Job Set & Job Entities23
Workflow Operations25
Asynchronous Operations25
Synchronous Operations26
JSON Structures27
Common Structures27
Specific Structures30
Working Examples65
Getting Started66
Requirements & Installation67
Structure of the Working Examples69
HTML Input Placeholders & Multiple Value Fields71
Display of Working Example Results72
Using the Working Examples with Server Security74
Server Security & Authentication75
Authenticating with the Server76
Working with the File Store80
Uploading a Data File to the File Store81
Uploading a Data Mapping Configuration to the File Store87
Uploading a Design Template to the File Store93
Page 5
Uploading a Job Creation Preset to the File Store99
Uploading an Output Creation Preset to the File Store105
Working with the Entity Services111
Finding Specific Data Entities in the Server112
Finding all the Data Sets in the Server144
Finding the Data Records in a Data Set147
Finding all the Content Sets in the Server151
Finding the Content Items in a Content Set154
Finding all the Job Sets in the Server158
Finding the Jobs in a Job Set161
Working with the Workflow Services164
Running a Data Mapping Operation165
Running a Data Mapping Operation (Using JSON)172
Running a Data Mapping Operation for PDF/VT File (to Data Set)179
Running a Data Mapping Operation for PDF/VT File (to Content Set)186
Running a Content Creation Operation for Print193
Running a Content Creation Operation for Print By Data Record (Using JSON)200
Running a Content Creation Operation for Email By Data Record (Using JSON)207
Creating Content for Web By Data Record218
Creating Content for Web By Data Record (Using JSON)224
Running a Job Creation Operation (Using JSON)230
Running an Output Creation Operation237
Running an Output Creation Operation (Using JSON)245
Running an Output Creation Operation By Job (Using JSON)253
Running an All-In-One Operation (Using JSON)261
REST API Reference277
Authentication Service282
Service Handshake283
Authenticate/Login to Server284
Service Version286
Content Creation Service287
Service Handshake288
Process Content Creation289
Process Content Creation (By Data Record) (JSON)291
Create Preview PDF293
Create Preview PDF (JSON)295
Create Preview PDF (By Data Record)297
Page 6
Get All Operations299
Get Progress of Operation300
Get Result of Operation302
Cancel an Operation304
Service Version305
Content Item Entity Service306
Service Handshake307
Get Data Record for Content Item308
Get Content Item Properties310
Update Content Item Properties312
Update Multiple Content Item Properties314
Service Version316
Content Set Entity Service317
Get All Content Set Entities318
Get Content Items for Content Set319
Get Page Details for Content Set321
Delete Content Set Entity323
Get Content Set Properties325
Update Content Set Properties327
Service Version329
Data Record Entity Service330
Service Handshake331
Add Data Records332
Get Data Record Values334
Update Data Record Values336
Get Data Record Properties338
Update Data Record Properties340
Get Multiple Data Record Values342
Update Multiple Data Record Values344
Update Multiple Data Record Properties346
Service Version348
Data Set Entity Service349
Get All Data Set Entities350
Get Data Records for Data Set351
Delete Data Set Entity352
Get Data Set Properties354
Update Data Set Properties356
Page 7
Service Version358
Data Mapping Service359
Service Handshake360
Process Data Mapping361
Process Data Mapping (JSON)363
Process Data Mapping (PDF/VT to Data Set)366
Process Data Mapping (PDF/VT to Content Set)368
Get All Operations370
Get Progress of Operation371
Get Result of Operation373
Cancel an Operation375
Service Version376
Document Entity Service377
Service Handshake378
Get Document Metadata Properties379
Update Document Metadata Properties381
Service Version383
Document Set Entity Service384
Service Handshake385
Get Documents for Document Set386
Get Document Set Metadata Properties388
Update Document Set Metadata Properties390
Service Version392
Content Creation (Email) Service393
Service Handshake394
Process Content Creation (By Data Record) (JSON)395
Get All Operations397
Get Progress of Operation398
Get Result of Operation400
Cancel an Operation402
Service Version404
Entity Service405
Service Handshake406
Find Data Entity407
Service Version409
File Store Service410
Service Handshake411
Page 8
Download Managed File or Directory412
Delete Managed File or Directory414
Upload Data Mapping Configuration416
Upload Job Creation Preset418
Upload Data File420
Upload Design Template422
Upload Output Creation Preset424
Service Version426
Content Creation (HTML) Service427
Service Handshake428
Process Content Creation (By Data Record)429
Process Content Creation (By Data Record) (JSON)431
Get Template Resource433
Service Version435
Job Creation Service436
Service Handshake437
Process Job Creation438
Process Job Creation (JSON)440
Process Job Creation (JSON Job Set Structure)442
Get All Operations444
Get Progress of Operation445
Get Result of Operation447
Cancel an Operation449
Service Version450
Job Entity Service451
Service Handshake452
Get Content Items for Job453
Get Job Segments for Job455
Get Job Metadata Properties456
Update Job Metadata Properties458
Get Job Properties460
Update Job Properties462
Update Multiple Job Properties464
Service Version465
Job Segment Entity Service466
Service Handshake467
Get Document Sets for Job Segment468
Page 9
Get Job Segment Metadata Properties470
Update Job Segment Metadata Properties472
Service Version474
Job Set Entity Service475
Get All Job Set Entities476
Get Jobs for Job Set477
Delete Job Set Entity478
Get Job Set Metadata Properties480
Update Job Set Metadata Properties482
Get Job Set Properties484
Update Job Set Properties486
Service Version488
Output Creation Service489
Service Handshake490
Process Output Creation491
Process Output Creation (JSON)493
Process Output Creation (By Job) (JSON)495
Get All Operations497
Get Progress of Operation498
Get Result of Operation500
Get Result of Operation (as Text)502
Cancel an Operation504
Service Version505
All-In-One Service506
Service Handshake507
Process All-In-One (JSON)508
Process All-In-One (Adhoc Data)510
Get All Operations514
Get Progress of Operation515
Get Result of Operation517
Get Result of Operation (as Text)519
Cancel an Operation521
Service Version522
Copyright Information523
Legal Notices and Acknowledgments524
Page 10
Welcome to the PlanetPress Connect
REST API Cookbook
This guide is aimed at technically experienced users who wish to learn and use the REST API
available in PlanetPress Connect version 1.7.1.
The PlanetPress Connect REST API consists of many services that expose access to a
number of areas including workflow, data entity management and file store operations.
These services can be used to perform various interactions with the PlanetPress Connect
server such as:
l Upload & Manage Data Files, Data Mapping Configurations & Design Templates in File
Store
l Create, Manage & Find Data Entities internal to the PlanetPress Connect Server
l Create & Monitor Processing Operations within the Workflow
The REST API also supports added security to restrict unauthorized access to the services.
This guide is broken down into three sections:
l Technical Overview - Overview of the concepts and structures used in PlanetPress
Connect and the REST API
l Working Examples - Working examples of the PlanetPress Connect REST API in action
(HTML5 & JavaScript/jQuery)
l REST API Reference - A complete reference to the PlanetPress Connect REST API &
Services
It is recommended that the technical overview section be read first, followed by the working
examples, using the REST API reference for greater detail on implementing any specific
example.
Page 11
Technical Overview
This section provides an overview of the concepts and structures used within PlanetPress
Connect and the REST API.
l Workflow & Workflow Processes
l Input Files
l Data Entities
l Workflow Operations
l JSON Structures
Page 12
Workflow & Workflow Processes
The primary workflow in PlanetPress Connect consists of four major processes that each
require a number of inputs, and once executed, produce a particular form of output. These
processes are: data mapping, content creation, job creation and output creation.
There is an additional workflow process, named All-In-One, which embodies all four major
workflow processes in a singular process.
The following diagram illustrates the primary workflow in PlanetPress Connect:
Typically an individual workflow process (shown above in blue) will take one or more input files
as input (shown above in green), and will produce either intermediary output in the form of a
data entity (shown above in red), or final output in the form of print, web, or email based content
(depending on the context of the content produced) (shown above in yellow).
Input files to a workflow process include files such as data files, data mapping configurations
and design templates. In most cases an input file needs to be uploaded to the server file store
before it can be used in a workflow process. A file that has been uploaded to the file store is
known as a managed file, and managed files can be referenced via a unique identifier or name.
A data entity is simply a structured data artefact, produced as a result of an instance of a
workflow process known as a workflow operation. Data entities are stored internally to the
server and can also be referenced via a unique identifier.
Where a certain process depends on the output of the process before it, the data entity or
entities produced by the earlier process are used as an input to that process.
Page 13
Data Mapping
The data mapping process involves taking a data file or source, applying a data mapping
configuration to it, and producing a structured set of data or data records (a data set). This
process can also produce a data set or content set from a PDF/VTfile using its internal meta
data instead of a data mapping configuration.
The following diagram illustrates the default workflow for the data mapping process:
The following diagram illustrates the alternative workflow for the data mapping process when
using PDF/VT data files specifically:
Page 14
Content Creation
The content creation process involves taking either a data set or one or more data records (from
a data set), combining them with a suitable design template, and producing one or more sets of
content (content sets). If the content is for the Email or Web context then output can be
produced at this stage.
The following diagram illustrates the workflow for the content creation process:
Page 15
Job Creation
The job creation process involves taking one or more content sets and applying a job creation
preset for organizing, sorting and grouping them into a set of logical jobs (a job set). This
includes the application of data filtering and finishing options.
The following diagram illustrates the workflow for the job creation process:
Page 16
Output Creation
The output creation process involves taking either a job set or one or more jobs (from a job set),
applying an output creation preset, and producing the print output (Print context).
The following diagram illustrates the workflow for the output creation process:
Page 17
All-In-One
The All-In-One process embodies all four major workflow processes (data mapping, content
creation, job creation and output creation) in a singular process. It can be configured to run one
or more of the four processes, as long as the processes specified result in a logical sequence
or workflow.
Depending on it's configuration, the All-In-One process can produce either a data set, content
sets, a job set or print output (Print context).
The following diagram illustrates the potential inputs, outputs and workflows for the All-In-One
process:
The following table lists the available processes, input combinations and expected outputs for
the All-In-One process:
Page 18
ProcessesInput CombinationExpected
Output
Data Mapping OnlyData File + Data Mapping ConfigurationData Set
Data Mapping +
Content Creation
Content Creation OnlyData Records + Design TemplateContent Set(s)
Data File + Data Mapping Configuration +
Design Template + Output Creation Preset
Data File + Data Mapping Configuration +
Design Template + Job Creation Preset +
Output Creation Preset
Print Output
Print Output
Page 19
Input Files
Input files are used as input to a specific workflow process. The following table lists the types of
input files used in the PlanetPress Connect workflow:
There are many data entity types used by PlanetPress Connect, but not all data entities can be
accessed through the REST API. The main data entities to be aware of when working with the
API are:
l Data Sets
l Data Records
l Content Sets
l Content Items
l Job Sets
l Jobs
Data Set & Data Record Entities
The data set is the artefact produced by a data mapping operation. It holds the data that was
mapped out of the input data file. A data mapping operation produces a single data set, which
contains as many data records as there are documents.
Each data record contains a collection of data values. The data records in the data set form the
master record, or document record, which typically contains document recipient information.
The master record can also contain a collection of data tables, which form the detail records
that hold data such as invoice line items.
Each data table contains a collection of data records, where each data record contains a
collection of data values and a collection of data tables, and so on.
Page 21
The following diagram illustrates the basic relationship between these entities in the context of
the data mapping process:
The data set and data record entities (shown above in blue) are accessible via the Data Set
Entity and Data Record Entity services.
Content Set & Content Item Entities
The content set is the artefact produced by a content creation operation. It holds all the pages
that were produced by the operation. A content creation operation produces one or more
content sets, which contain as many content items as there were data records given at the start
of the operation.
Because the data records used may have different data set owners, a content set cannot be
linked to a single data set, but rather content items are linked to data records. A content item is
further divided into content sections and content pages.
The following diagram illustrates the basic relationship between these entities in the context of
the content creation process:
Page 22
The content set and content item entities (shown above in blue) are accessible via the Content
Set Entity and Content Item Entity services.
Job Set & Job Entities
The job set is the artefact produced by a job creation operation. It consists of a hierarchical
structure that divides documents into various structures and it basically decides which
documents are to be printed and in what order.
A job creation operation creates a single job set which contains a series of containers where
every level contains one or more of the next level down: jobs, job segments, document sets,
documents and document pages. The last level in the chain, the document pages, contains a
single content item. Hence, at the job creation level, a document may consist of one or more
content items.
The following diagram illustrates the basic relationship between these entities in the context of
the job creation process:
The job set and job entities (shown above in blue) are accessible via the Job Set Entity and
Job Entity services. The job segment, document set and document entities (also shown above
in blue) are accessible via the Job Segment Entity, Document Set Entity and Document Entity
services.
In summary, the following diagram illustrates the basic relationship between all data entities in
Page 23
the overall context of the primary workflow in PlanetPress Connect:
Page 24
Workflow Operations
Each individual process in the overall workflow can potentially be a long running operation.
Accordingly, there are two types of workflow operations possible in the PlanetPress Connect
REST API:
l Asynchronous – the operation is initiated, monitored, and the result returned using
multiple requests (Default)
l Synchronous – the operation is initiated and the result returned using a single request
Asynchronous Operations
Asynchronous workflow operations require the submission of an initial HTTP request to initiate
the operation. Then additional requests are required to monitor progress and retrieve the final
result. All the required detail is included in the HTTP response headers of the initial request,
including the URIs that should be used for further processing.
A successful request will return a response that will include the headers listed in the following
table:
HeaderDescription
operationIdThe unique id of the operation being processed
LinkContains multiple link headers which provide details on which URI to use to
retrieve further information on the operation:
l Header with rel="progress" - The URL to use to check the progress of
the operation
l Header with rel="result" - The URL to use to retrieve the result of the
operation
l Header with rel="cancel" - The URL to use to cancel the operation
A request made to the progress URI during processing will return a progress percentage value
of 0 to 100, and finally the value of ‘done’ once the operation has completed.
Page 25
A request made to the cancel URI during processing will immediately cancel the operation.
A request made to the result URI after processing has completed will return the final result of
the operation.
This is the default workflow operation type, and this approach is used across most workflow
based services as demonstrated in the Working with the Workflow Services page of the
Working Examples section.
Synchronous Operations
Synchronous workflow operations initiate the operation and retrieve the final result in a single
request.
There are no additional operation related headers returned, and there is no option to either
monitor progress or cancel a running operation.
This approach is only used by specific methods found in the All-In-One workflow service.
Page 26
JSON Structures
The PlanetPress Connect REST API uses various JSON structures to describe certain inputs
and outputs to resource methods.
These structures can be broken down into the following categories:
l Common - Structures that are commonly used throughout the REST API
l Specific - Structures that are used by a specific resource method or service in the REST
API
Common Structures
Common JSON structures used in the PlanetPress Connect REST API include the following:
JSON Identifier
Describes an identifier for a single data entity or managed file in PlanetPress Connect.
The structure consists of an object with a single name/value pair:
l identifier - the data entity or managed file identifier (type of number)
Example:
{
"identifier": 12345
}
JSON Identifier (Named)
Describes a named identifier for a single managed file in PlanetPress Connect.
The structure consists of an object with a single name/value pair:
l identifier - the managed file named identifier (type of string)
Example:
{
"identifier": "Promo-EN-1000.csv"
Page 27
}
JSON Identifier List
Describes a list of identifiers for multiple data entities in PlanetPress Connect.
The structure consists of an object with a single name/value pair:
l identifiers - an array of data entity identifiers (type of number)
Example:
{
"identifiers": [ 12345, 23456, 34567 ]
}
JSON Name/Value List (Properties Only)
Describes a list of properties (each as a name/value pair).
The structure consists of an array of objects each with the following name/value pairs:
l name - the name of the property (type of string)
l value - the value of the property (type of string)
Example:
[
{
"name": "start",
"value": "2015-01-01 00:00:00T-0500"
},
{
"name": "end",
"value": "2015-12-31 23:59:59T-0500"
}
]
JSON Name/Value List
Describes a list of properties (each as a name/value pair) for a data entity of a specific ID.
The structure consists of an object with the following name/value pairs:
Page 28
l id - the data entity identifier (type of number)
l properties - the data entity properties, consisting of an array of objects each with the
following name/value pairs:
l name - the name of the property (type of string)
l value - the value of the property (type of string)
Example:
{
"id": 12345,
"properties": [
{
"name": "start",
"value": "2015-01-01 00:00:00T-0500"
},
{
"name": "end",
"value": "2015-12-31 23:59:59T-0500"
}
]
}
JSON Name/Value Lists
Describes multiple lists of properties (as name/value pairs) for data entities of a specific ID.
The structure consists of an array of JSON Name/Value List structure objects.
Example:
[
{
"id": 12345,
"properties": [
{
"name": "start",
"value": "2015-01-01 00:00:00T-0500"
},
{
"name": "end",
"value": "2015-12-31 23:59:59T-0500"
Page 29
}
]
},
{
"id": 23456,
"properties": [
{
"name": "start",
"value": "2015-01-01 00:00:00T-0500"
},
{
"name": "end",
"value": "2015-12-31 23:59:59T-0500"
}
]
}
]
Specific Structures
Specific JSON structures used in the PlanetPress Connect REST API include the following:
JSON Identifier (with createOnly flag)
Describes an identifier for a single job set entity, along with additional parameters used
specifically in an output creation operation.
The structure consists of an object with the following name/value pairs:
l identifier - the job set entity identifier (type of number)
l createOnly - flag to specify if output is to be only created in the server and not sent to it's
final destination (type of boolean)
Example:
{
"identifier": 12345,
"createOnly": true
}
Page 30
JSON Identifier List (with createOnly flag)
Tip
A data record entity (in the record data table) can contain one or more data tables that
each contain one or more data record entities (nested data record entities).
A nested data record entity can itself contain one or more data tables that each contain
one or more nested data record entities, and so on for potentially multiple levels of nested
data tables and data record entities.
A data record entity that contains a data table of nested data record entities is considered
to be the parent of the data record entities contained in that data table (which are
considered to be the children).
See the Data Entities page of the Technical Overview section for further detail on data set
and data record entities.
Describes a list of identifiers for multiple job entities, along with additional parameters used
specifically in an output creation operation.
The structure consists of an object with the following name/value pairs:
l identifiers - an array of job entity identifiers (type of number)
l createOnly - flag to specify if output is to be only created in the server and not sent to it's
Describes a list of data fields (as name/value pairs), nested data records (if any), along with a
number of additional properties for a data record entity of a specific ID.
The structure consists of an object with the following name/value pairs:
Page 31
l id - the data record entity identifier (type of number)
l fields - a list of data fields in the data record entity, consisting of an array of objects
each with the following name/value pairs:
l name - the name of the data field (type of string)
l value - the value of the data field (type of string)
l records - a list of any nested data record entities, consisting of an array of objects each
with the following name/value pairs:
l id - the data record entity identifier (type of number)
l table - the data record entity data table name (type of string)
l parentrecordid - the data record entity identifier of parent entity (type of number)
l fields - a list of data fields in the data record entity, consisting of an array of
objects each with the following name/value pairs:
l name - the name of the data field (type of string)
l value - the value of the data field (type of string)
Specific to data record entities that are children of a data set entity (data record entities in the
record data table), two additional name/value pairs are included:
l table - the data record entity data table name (value of record) (type of string)
l datasetid - the data set entity identifier of parent entity (type of number)
Specific to nested data record entities that are children of a data record entity, two additional
name/value pairs are included:
l table - the data record entity data table name (type of string)
l parentrecordid - the data record entity identifier of parent entity (type of number)
Describes multiple lists of data field values (as name/value pairs), nested data records (if any),
along with a number of additional properties for data record entities of a specific ID.
The structure consists of an array of JSON Record Content List structure objects.
"name": "ItemDesc",
"value": "Upgrade (Starter to Web)"
},
{
"name": "ItemUnitPrice",
"value": "495.00"
},
{
"name": "ItemOrdered",
"value": "1"
}
{
"name": "ItemTotal",
"value": "495.00"
}
]
Page 37
]
JSON Record Content List (Fields Only)
Describes a list of data field values (as name/value pairs) for a data record, used to update an
existing data record entity of a specific ID.
The structure consists of an object with the following name/value pairs:
l id - the data record entity identifier (type of number)
l fields - a list of data fields in the data record entity, consisting of an array of objects
each with the following name/value pairs:
l name - the name of the data field (type of string)
l value - the value of the data field (type of string)
Example:
{
"id": 12345,
"fields": [
{
"name": "FirstName",
"value": "Benjamin"
},
{
"name": "LastName",
"value": "Verret"
}
]
}
JSON Record Content Lists (Fields Only)
Describes multiple lists of data field values (as name/value pairs) for a data record, used to
update existing data record entities of a specific ID.
The structure consists of an array of JSON Record Content List (Fields Only) structure objects.
Example:
[
{
"id": 12345,
Page 38
"fields": [
{
"name": "FirstName",
"value": "Benjamin"
},
{
"name": "LastName",
"value": "Verret"
}
]
},
{
"id": 23456,
"fields": [
{
"name": "FirstName",
"value": "Dianne"
},
{
"name": "LastName",
"value": "Straka"
}
]
}
]
JSON New Record List
Describes a list of new data records (and their data field values (as name/value pairs)) to be
added as data record entities to either an existing data set or data record entity of a specific ID.
The structure consists of an object with the following name/value pairs:
l records - a list of the new data records to be added, consisting of an array of objects
each with the following name/value pairs:
l fields - a list of data fields for the data record, consisting of an array of objects
each with the following name/value pairs:
l name - the name of the data field (type of string)
l value - the value of the data field (type of string)
Page 39
Specific to the adding of data records to the record data table of an existing data set entity, an
additional name/value pair is included:
l datasetid - the data set entity identifier of parent entity (type of number)
Specific to the adding of nested data records to a data table of an existing data record entity,
two additional name/value pairs are included:
l recordid - the data record entity identifier of parent entity (type of number)
l table - the data record entity data table name (type of string)
Describes multiple lists of new data records (and their data field values (as name/value pairs))
to be added as data record entities to either existing data set or data record entities of a specific
ID.
The structure consists of an array of JSON New Record List structure objects.
Describes a list of content item/data record entity identifier pairs (as name/value pairs) for a
specific content set entity.
The structure consists of an object with the following name/value pairs:
l identifiers - the data entity identifier pairs, consisting of an array of objects each with
the following name/value pairs:
Example:
{
"identifiers": [
]
}
l item - the content item entity identifier (type of number)
l record - the data record entity identifier (type of number)
{
"item": 12345,
"record": 54321
},
{
"item": 23456,
"record":65432
},
{
"item": 34567,
"record": 76543
}
Page 45
JSON Data Record Identifier
Describes a single data record entity identifier for a specific content item entity.
The structure consists of an object with a single name/value pair:
l record - the data record entity identifier (type of number)
Example:
{
"record": 12345
}
JSON Identifier List (with Email Parameters)
Describes a list of identifiers for multiple data entities (specifically data record entities), along
with additional parameters used specifically in an content creation operation for email.
The structure consists of an object with the following name/value pairs:
l identifiers - an array of data record entity identifiers (type of number)
l host - the network address or name of the SMTP mail server through which emails will be
sent (type of string)
l user - the user name to authenticate with (if using authentication) (type of string)
l password - the password to authenticate with (if using authentication) (type of string)
l sender - the email address to be shown as the sender in the email output (type of string)
l useAuth - parameter to specify if authentication is to be used with the mail server (type of
boolean)
l useStartTLS - parameter to specify if Transport Layer Security (TLS) is to be used when
sending emails (type of boolean)
l useSender - parameter to specify if the sender address will be used as the receiver
address for all emails in the output (type of boolean)
l attachWebPage - parameter to specify if a single HTML web page (with embedded
resources) of the Web context should also be created and attached to the email output
(type of boolean)
l attachPdfPage - parameter to specify if a PDF of the Print context should also be created
and attached to the email output (type of boolean)
Describes a list of parameters used specifically in the creation of web content.
The structure consists of an object with the following name/value pairs:
l section - the section within the Web context of the template to use (type of string)
l inline - the inline mode to be used in the creation of content (value of either NONE, CSS or
ALL) (type of string)
Example:
{
"section": "Section 1",
"inline": "ALL"
}
JSON Job Set Structure
Describes a job set entity structure including the arrangement of job, job segment, document
set, document and content item entities (including the specification of content item identifiers).
Used specifically in a job creation operation.
The structure consists of an object with the following name/value pairs:
Page 47
l jobs - the job entities within the job set, consisting of an array of objects each with the
following name/value pairs:
l segments - the job segment entities within a job, consisting of an array of objects
each with the following name/value pairs:
l documentsets - the document set entities within a job segment, consisting of
an array of objects each with the following name/value pairs:
l documents - the document entities within a document set, consisting of
an array of objects each with the following name/value pairs:
l documentpages - the document pages within a document,
consisting of an array of objects each with a single name/value
pair:
l contentitem - the identifier of the content item entity within a
document page (type of number)
Example:
{
"jobs": [
{
"segments": [
{
"documentsets": [
{
"documents": [
{
"documentpages": [
{
"contentitem": 111
},
{
"contentitem": 222
}
]
},
{
"documentpages": [
{
"contentitem": 456
}
]
Page 48
}
]
}
]
}
]
},
{
"segments": [
{
"documentsets": [
{
"documents": [
{
"documentpages": [
{
"contentitem": 789
}
]
}
]
}
]
}
]
}
]
}
JSON All-In-One Configuration
Describes the configuration of an All-In-One operation as a series of name/value pairs
representing the processes (data mapping, content creation, job creation and output creation) to
be completed as part of the overall operation. The value in each pair contains the parameters
for that specific process.
The structure is variable, allowing for configurations containing one or more specific processes
(as name/value pairs), as long as the processes specified result in a logical sequence or
workflow. Used specifically with the All-In-One service.
The structure consists of an object with the following name/value pairs:
Page 49
l datamining - data mapping configuration parameters, consisting of an object with the
following name/value pairs:
l identifier - the managed file identifier (type of number) or named identifier (type of
string) of the data file
l config - the managed file identifier (type of number) or named identifier (type of
string) of the data mapping configuration
l contentcreation - content creation configuration parameters, consisting of an object with
the following name/value pairs:
l identifiers - an array of data record entity identifiers (type of number) (optional for
configurations containing data mapping parameters)
l config - the managed file identifier (type of number) or named identifier (type of
string) of the input design template
l jobcreation - job creation configuration parameters, consisting of an object with the
following name/value pairs:
l config - the managed file identifier (type of number) or named identifier (type of
string) of the job creation preset (optional)
l outputcreation - output creation configuration parameters, consisting of an object with
the following name/value pairs:
l identifiers - an array of job entity identifiers (type of number) (optional for
l config - the managed file identifier (type of number) or named identifier (type of
string) of the output creation preset
l createOnly - flag to specify if output is to be only created in the server and not sent
to it's final destination (type of boolean)
Specific to the use of all processes (and their parameters), an additional name/value pair can
be added to restrict the print output to a set of specific records in the input data:
l printRange - print range configuration parameters, consisting of an object with a single
name/value pair:
l printRange - the range of records in the data file to output (type of string).
Describes a summary of the page details for a specific content set entity.
Page details include the number of pages per media type, along with media specific properties
including the name, size, width and height. Used specifically with the Content Set Entity
service.
The structure consists of an object with the following name/value pairs:
l pages - a list of the total pages per media, consisting of an array of objects each with the
following name/value pairs:
Example:
{
"pages": [
l count - the number of pages using the specific media (type of number)
l media - media specific properties, consisting of an object with the following
name/value pairs:
l name - the name of the media (type of string)
l size - the size of the media (type of string)
l width - the width of the media (type of string)
l height - the height of the media (type of string)
"name": "Plain Letter Paper",
"size": "Letter",
"width": "8.5in",
"height": "11in"
}
}
]
}
JSON Page Details List
Describes a list of the the page details and identifiers for each content item contained within a
specific content set entity.
Page details include the number of pages per media type, along with media specific properties
including the name, size, width and height. Used specifically with the Content Set Entity
service.
The structure consists of an array of objects each with the following name/value pairs:
l id - the content item entity identifier (type of number)
l pages - a list of the pages per media, consisting of an array of objects each with the
following name/value pairs:
l count - the number of pages using the specific media (type of number)
l media - media specific properties, consisting of an object with the following
name/value pairs:
l name - the name of the media (type of string)
l size - the size of the media (type of string)
l width - the width of the media (type of string)
l height - the height of the media (type of string)
"name": "Plain Letter Paper",
"size": "Letter",
"width": "8.5in",
"height": "11in"
}
}
]
Page 54
]
JSON Data Mapping Validation Result
Describes the result of a request to validate a data mapping operation, including a list of any
errors that occurred (used specifically with the Data Mapping service).
The structure consists of an object with the following name/value pairs:
l result - the overall result of the data mapping operation (value of either ERROR or OK) (type
of string)
l recordcount - the number of data records in the data file (type of number)
l errors - a list of errors that occurred during the mapping process, consisting of an array
of objects each with the following name/value pairs:
l record - the number of the erroneous record in the data file (type of number)
l reason - the mapping error/reason for this particular record (type of string)
Describes a set of complex search criteria broken into search, sorting and grouping rules. This
structure is used specifically with the Entity service as input to the Find Data Entity resource
Page 55
method.
Note
Certain search, sorting or grouping rules can only be used with specific data entity types.
See the Finding Specific Data Entities in the Server page of the Working Examples
section for further detail on the available rule combinations.
Search rules can be added to a search rules list and can be used to match data entities based
on specific criteria. This rules list also specifies an operator which determines whether all rules
or only one rule in the list is required to be matched.
Search rules can be based on data record values, data entity properties, finishing options,
document length, template names and whether an entity's identifier is contained or not
contained in a list of identifiers.
Rule groups can also be added to this search rules list, and each rule group contains it's own
sub list of search rules and its' own rule operator. Rule groups can also be added to the search
rule list of an existing rule group which allows for the construction of complex search criteria.
Sorting rules can be also added to a sort rules list and (depending on the data entity type) can
be used to sort data entity entries in the search results by either data record values or data
entity properties.
Every sort rule added will expand the value of the sort key of each entry listed in the resulting
JSON Identifier Lists (with Sort Key) structure.
Grouping rules can be also added to a group rules list and (depending on the data entity type)
can be used to group data entity entries in the search results by either data record values or
data entity properties.
Every group rule added can expand the number of sub lists contained in the resulting JSON
Identifier Lists (with Sort Key) structure.
The structure consists of an object with the following name/value pairs:
Page 56
l entity - the data entity type (value of either DATARECORDS, DATASETS, CONTENTITEMS,
CONTENTSETS, JOBS or JOBSETS) (type of string)
l search - search criteria, consisting of an object with the following name/value pairs:
l operator - the search rule operator for the base list of rules (value of either AND or OR)
(type of string)
l rules - a base list of search rules, consisting of an array of objects each with a
specific rule sub-structure depending on the type of rule
l sort - a list of sorting rules, consisting of an array of objects each with the following
name/value pairs:
l name - the name of the data value field or data entity property to sort by (type of
string)
l order - the order that matches to this rule are sorted by (value of either ASC or DESC)
(type of string)
l type - the type of sorting rule (value of either value or property) (type of string)
Sorting rule objects with a type value of value also contain the following additional
name/value pair:
l numeric - whether the data value field is a of a numeric type (type of boolean)
l group - a list of grouping rules, consisting of an array of objects each with the following
name/value pairs:
l name - the name of the data value field or data entity property to group by (type of
string)
l order - the order that matches to this rule are grouped by (value of either ASC or
DESC) (type of string)
l type - the type of grouping rule (value of either value or property) (type of string)
Grouping rule objects with a type value of value also contain the following additional
name/value pair:
l numeric - whether the data value field is a of a numeric type (type of boolean)
The search rule sub-structure consists of an object with rule specific groupings of name/value
pairs as follows.
Page 57
Search rule objects with a type value of value contain the following name/value pairs:
l type - the type of search rule (value of value) (type of string)
l name - the name of the data field (type of string)
l value - the value of the data field (type of string, or array of strings when
condition is value of either IN or NOT IN)
l condition - the comparison condition (value of either EQUAL, NOTEQUAL, LESS, GREAT,
LESSEQUAL, GREATEQUAL, STARTSWITH, ENDSWITH, CONTAINS, LIKE, NLIKE, IN or NOT IN)
(type of string)
Search rule objects with a type value of property contain the following name/value pairs:
l type - the type of search rule (value of property) (type of string)
l name - the name of the data entity property (type of string)
l value - the value of the data entity property (type of string, or array of strings
when condition is value of eitherIN or NOT IN)
l condition - the comparison condition (value of either EQUAL, NOTEQUAL, LESS, GREAT,
LESSEQUAL, GREATEQUAL, STARTSWITH, ENDSWITH, CONTAINS, LIKE, NLIKE, IN or NOT IN)
(type of string)
Search rule objects with a type value of either IN or NOT IN contain the following
name/value pairs:
l type - the type of search rule (value of either IN or NOT IN) (type of string)
l identifiers - an array of data entity identifiers (type of number)
Search rule objects with a type value of finishing contain only one of the following sub-
groups of name/value pairs:
l type - the type of search rule (value of finishing) (type of string)
l medianame - the name of the media used (type of string)
l condition - the comparison condition (value of either EQUAL or NOTEQUAL) (type of
string)
l type - the type of search rule (value of finishing) (type of string)
l duplex - whether the page sheet is duplex (type of boolean)
Page 58
l type - the type of search rule (value of finishing) (type of string)
l frontcoating - the front coating of the media used (value of either UNSPECIFIED,
NONE, COATED, GLOSSY, HIGH_GLOSS, INKJET, MATTE, SATIN or SEMI_GLOSS) (type of
string)
l backcoating - the back coating of the media used (value of either UNSPECIFIED, NONE,
COATED, GLOSSY, HIGH_GLOSS, INKJET, MATTE, SATIN or SEMI_GLOSS) (type of string)
l condition - the comparison condition (value of either EQUAL or NOTEQUAL) (type of
string)
l type - the type of search rule (value of finishing) (type of string)
l bindingstyle - the binding style of the media used (value of either NONE, DEFAULT,
STAPLED, GLUED, STITCHED, ADHESIVE, SPINETAPING, RING, WIREDCOMB, PLASTICCOMB or
COIL) (type of string)
l bindingedge - the binding edge of the media used (value of either DEFAULT, LEFT,
RIGHT, TOP or BOTTOM) (type of string)
l bindingtype - the binding type of the media used (value of either DEFAULT, SADDLE,
SIDE or CORNER) (type of string)
l bindingangle - the binding angle of the media used (value of either DEFAULT,
VERTICAL, HORIZONTAL or ANGLE) (type of string)
l condition - the comparison condition (value of either EQUAL or NOTEQUAL) (type of
string)
Search rule objects with a type value of doclength contain the following name/value
pairs:
l type - the type of search rule (value of doclength) (type of string)
l value - the number of pages in document (type of number)
l condition - the comparison condition (value of either EQUAL, NOTEQUAL, LESS, GREAT,
LESSEQUAL or GREATEQUAL) (type of string)
Search rule objects with a type value of templatename contain the following name/value
pairs:
Page 59
l type - the type of search rule (value of templatename) (type of string)
l template - the name of the design template used for document (type of string)
l condition - the comparison condition (value of either EQUAL or NOTEQUAL) (type of
Search rule group objects contain the following name/value pairs:
l operator - the search rule operator for sub-list of rules in rule group (value of either
l rules - a sub-list of search rules, consisting of an array of objects each with a
Examples:
{
"entity": "CONTENTITEMS",
"search": {
string)
AND or OR) (type of string)
certain rule sub-structure depending on the type of rule
Describes a set of search results as a list of one or more sub lists, each containing a list of data
entity identifiers along with a sorting key value for each entry.
Used specifically with the Entity service as the output from the Find Data Entity resource
method, this structure groups the data entity identifiers returned into sortable sub lists of entries.
The order of the entries (including the sort key produced), and the number of sub lists returned
depends on the sorting and grouping rules specified in the JSON Search Parameters structure
previously submitted as input to the Find Data Entity resource method.
The structure consists of an array of object arrays, with each object containing the following
name/value pairs:
l identifier - the data entity identifier (type of number)
l sortkey - the data entity sort key (type of string)
Page 61
Example:
Note
See the Workflow Operations page of the Technical Overview section for further detail on
[
[
]
]
{
"identifier": 1604,
"sortkey": "NB|Vilma"
},
{
"identifier": 1282,
"sortkey": "NF|Lenard"
},
{
"identifier": 1443,
"sortkey": "NF|Lenard"
},
{
"identifier": 1000,
"sortkey": "SK|Cathleen"
},
{
"identifier": 1121,
"sortkey": "SK|Rachel"
}
JSON Operations List
Describes a list of workflow operations (specifically asynchronous workflow operations)
actively running on the server, each containing various properties including the type of
workflow operation, it's starting time and it's current progress value.
This structure is used specifically with workflow based services including the Data Mapping,
Content Creation, Content Creation (Email), Job Creation, Output Creation and All-In-One
services.
Page 62
workflow operations.
The structure consists of an array of objects each with the following name/value pairs:
l id - the workflow operation identifier (type of string)
l type - the workflow operation type (value of either DataMiningRestService,
ContentCreationRestService, EmailExportRestService, JobCreationRestService,
OutputCreationRestService or PrintRestService) (type of string)
l subTask - the workflow operation sub-task name (type of string)
l startTime - the workflow operation starting time stamp (value of milliseconds since
midnight of January 1, 1970 UTC) (type of number)
l progress - the workflow operation progress percentage (value in range of 0 to 100) (type of
number)
Workflow operation objects with a type value of either ContentCreationRestService or
PrintRestService (usually with a subTask value of Content Creation) can also contain the
following name/value pair:
l template - the name of the design template being used for content creation (type of
This section provides a number of working examples that demonstrate the use of the various
resources and methods available in the PlanetPress Connect REST API.
For help on getting started with the PlanetPress Connect REST API Cookbook and the working
examples, see the Getting Started page.
l Server Security & Authentication
l Working with the File Store
l Working with the Entity Services
l Working with the Workflow Services
Page 65
Getting Started
This guide provides many working examples to help illustrate the correct use of a given
API/method. To achieve this, the guide uses HTML5 & JavaScript/jQuery syntax, and thus,
some basic experience and knowledge of these technologies is assumed.
HTML5: http://www.w3schools.com/html/
jQuery: https://jquery.com/
Help on installing and getting started with the working examples can be found on the
Requirements & Installation and Structure of the Working Examples pages.
Important notes on general use of the working examples can be found in the HTML Input
Placeholders & Multiple Value Fields and Display of Working Example Results pages.
If you have server security settings enabled on your PlanetPress Connect server then the Using
the Working Examples with Server Security page should be read also.
Page 66
Requirements & Installation
Warning
If using Internet Explorer, you may find issues when using the working examples with
PlanetPress Connect's Server Security Settings set to enabled.
The working examples use HTML5 Local Storage to facilitate authentication and certain
simplicity / ease-of-use (across browser tabs). Depending on how your Internet Explorer
security settings are configured, you may experience issues if the security level of your
zone is set too high.
Essentially, the security zone needs to have the security option Userdata persistence
(under Miscellaneous) set to enabled. Without this option enabled, the working
examples will not function correctly when using them with PlanetPress Connect's ServerSecuritySettings set to enabled.
After running the Authenticate/Login to Server working example to re-authenticate, you
should only need to refresh existing pages in order for the authentication credentials
(token) to be picked up. In the case of Internet Explorer, you may need to restart the
browser for the changes to be picked up.
If all else fails, disabling of the Sever Security Settings in the PlanetPress Connect
Server Preferences should avoid issues with running the various examples on Internet
Explorer.
It is recommended that you use a modern web-browser other than Internet Explorer
when running the working examples.
Requirements
To use the PlanetPress Connect REST API Cookbook with Working Examples source you will
require the following:
1. A working installation of PlanetPress Connect
2. Any modern web browser able to display HTML5
1
1
Any recent version of Mozilla Firefox, Google Chrome, or Opera with support for HTML5 should be
suitable for running the working examples contained in this guide. Versions of Internet Explorer 10+ may
also be suitable in some cases.
Page 67
Installation
Note
You can access the PlanetPress Connect REST API Cookbook with Working Examples
source locally by entering the following URL in your web browser:
The working examples source comes pre-installed with PlanetPress Connect and can be
located in a sub-directory of your existing PlanetPress Connect installation directory.
To locate the source on Windows:
1. Open up Windows Explorer and navigate to the PlanetPress Connect installation
directory followed by its plugins sub-directory.
2. Find the com.objectiflune.serverengine.rest.gui directory and navigate to its www sub-
directory
3. You should now be exploring the following or similar location:
4. The www directory contains a cookbook sub-directory, which contains all of the working
examples source. You should find a directory structure matching that shown on the
Structure of the Working Examples page.
Page 68
Structure of the Working Examples
The working examples are designed to be complete examples, and will generally consists of
one HTML5 file paired with a JavaScript/jQuery module which can be found in the
examples/<service-name>/js/ sub-directory.
Where any frequent or boilerplate functionality is commonly used across the examples, this has
been moved to the common/js/common.js JavaScript/jQuery module.
The examples make use of this module for functionality such as setting up the example, and
displaying output results.
Page 69
The examples also make use of some simple CSS classes as defined in
common/css/styles.css and HTML snippets for the presentation of output results.
Page 70
HTML Input Placeholders & Multiple Value Fields
In the working examples, HTML input elements make use of the placeholder attribute to help
provide some indication of the type and format of the value expected to be entered / specified.
The following table lists examples of placeholders commonly used in the working examples:
HTMLExpected TypeExample Values
Single ID Value
Single ID or Name Value (File Name)
One or More ID Values (comma
separated)
Name (Text) Value
Numerical Range
l 2341
l 3
l 2341
l Promo-EN-1000.csv
l 2341, 2342
l 3456
l ol-admin
l Section 2
l 1, 2, 3
Email Address Value
Server Hostname Value
l 1-5
l 1, 2, 3-5, 6
l john.smith@contoso.com
l mailbox.contoso.com
Page 71
Display of Working Example Results
Note
In some examples the same result will displayed in both plain and JSON structure based
formats. This is to assist ease-of-use when working with outputs of one example that will
be needed as an input to another example.
When a working example is run, any results will be displayed in a Results area that will appear
below the working example existing HTML interface.
For example:
Page 72
A working example can be run multiple times, and each time the results will be appended
below allowing you to compare the output of varying inputs. The Clear button can be selected
at any time to clear all existing results.
Page 73
Using the Working Examples with Server Security
Note
Once re-authenticated, you shouldn’t see this dialog box again for as long as your
session remains active.
If you have the Server Security Settings set to enabled in your PlanetPress Connect Server
Preferences, then you may see the following dialog box initially display when working with the
examples:
In the event of this dialog box, just follow the instructions and either refresh the page or reÂauthenticate by running the Authenticating with the Server (Authenticate/Login to Server)
working example covered under the Server Security & Authentication section.
Page 74
Server Security & Authentication
Note
A complete listing including these examples can be found in the index.html file located
at the root of the working example source code which contains links to all working
examples.
This section consists of a number of pages covering various useful working examples:
1. Authenticating with the Server
See the Authentication Service page of the REST API Reference section for further detail.
Page 75
Authenticating with the Server
Problem
Your PlanetPress Connect Server is configured to use server security, and you want to
authenticate with the server to obtain the correct access to make future requests.
Solution
The solution is to create a request using the following URI and method type to authenticate with
the server via the Authentication REST service:
Authenticate/Login to Server
Example
HTML5
auth-login-server.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Authenticate/Login to Server Example</title>
<script src="../../common/lib/js/jquery-
To run the example simply enter your credentials into the Username and Password fields and
select the Submit button.
Page 78
Once selected, a request containing the credentials will be sent to the server and the result will
be returned and displayed to the Results area.
If authentication was successful then the response will contain an Authorization Token that
can be then used in the submission of future requests to the server.
Discussion
Firstly, we define an event handler that will run in response to the submission of the HTML form
via the selection of the Submit button.
When our event hander function is called, we then obtain the value of the Username and
Password fields. We define two variables, username to hold the value of the Username text
field and password to hold the value of the Password text field.
Next we construct an jQuery AJAX request which will be sent to the Authentication REST
service:
Method type and url arguments are specified as shown earlier.
We specify a beforeSend argument containing a function that will add an additional
Authorization header to the request to facilitate Basic HTTP Authentication. The value of
the Authorization request header is a Base64 digest of the username and password
variables.
When the request is successful or done, a request response is received and the content of that
response is passed as the function parameter response. In the example, we then display the
value of this parameter which should be the new Authorization Token which can then be used
in the submission of future requests to the server.
This is achieved by placing the value of the Authorization Token in the auth_token request
header of a future request. In the example the common function setSessionToken is used to
facilitate this function for all future working example requests.
Further Reading
See the Authentication Service page of the REST API Reference section for further detail.
Page 79
Working with the File Store
Note
A complete listing including these examples can be found in the index.html file located
at the root of the working example source code which contains links to all working
examples.
This section consists of a number of pages covering various useful working examples:
1. Uploading a Data File to the File Store
2. Uploading a Data Mapping Configuration to the File Store
3. Uploading a Design Template to the File Store
4. Uploading a Job Creation Preset to the File Store
5. Uploading an Output Creation Preset to the File Store
See the File Store Service page of the REST API Reference section for further detail.
Page 80
Uploading a Data File to the File Store
Problem
You want to upload a data file to the File Store so that it can be used as part of a Data Mapping
operation.
Solution
The solution is to create a request using the following URI and method type to submit the data
file to the server via the File Store REST service:
Upload Data File
Example
HTML5
fs-datafile-upload.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Upload Data File Example</title>
<script src="../../common/lib/js/jquery-
Only one Managed File in the file store can be associated with a specific name. If two
files are uploaded to the file store under the same name, then only the most recently
Usage
To run the example simply select the Browse button and then select the data file you wish to
upload using the selection dialog box.
Next you can specify the following options to use with the upload of the data file:
l Named - allow this file to be identified/referenced by its Managed File Name as well as its
Managed File ID
l Persistent - make this file persistent in the file store
Page 84
uploaded file will be associated with (or can be referenced using) that name.
Once the file and options are selected, simply select the Submit button to upload the file to the
server's file store and the resulting Managed File ID for the data file will be returned and
displayed to the Results area.
Discussion
Firstly, we define an event handler that will run in response to the submission of the HTML form
via the selection of the Submit button.
When our event handler function is called, we then obtain a reference to the local data file
previously selected. This is achieved by getting the first value of the files attribute of the HTML
element with the ID of datafile (in this case a file type input HTML element) and storing it in a
variable file.
We also obtain boolean values for the Named and Persistent options (both checkbox type
input HTML elements) and store them in the named and persistent variables respectively.
Next we construct a jQuery AJAX request which will be sent to the File Store REST service.
We use an object called settings to hold the arguments for our request:
Method type and url arguments are specified as shown earlier, with the addition of a
persistent query parameter which specifies whether the file is to be persistent in the file
store when uploaded.
We specify the variable file as the data or contents of the request, a contentType argument
of "application/octet-stream", and because we are sending file data we also specify a
processData argument set to false.
If the Named option is checked in our form, and the named variable is true, then a filename
query parameter is also added which contains the file name of the file selected (file.name).
Lastly, the settings object is passed as an argument to the jQuery AJAX function ajax and the
request is executed.
Page 85
When the request is successful or done, a request response is received and the content of that
response is passed as the function parameter response. In the example, we then display the
value of this parameter which should be the new Managed File ID of the data file in the file
store.
Further Reading
See the File Store Service page of the REST API Reference section for further detail.
Page 86
Uploading a Data Mapping Configuration to the File Store
Problem
You want to upload a data mapping configuration to the File Store so that it can be used as part
of a Data Mapping operation.
Solution
The solution is to create a request using the following URI and method type to submit the data
mapping configuration to the server via the File Store REST service:
Upload Data Mapping
Configuration
Example
HTML5
fs-datamapper-upload.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Upload Data Mapping Configuration Example</title>
<script src="../../common/lib/js/jquery-
Only one Managed File in the file store can be associated with a specific name. If two
Usage
To run the example simply select the Browse button and then select the data mapping
configuration you wish to upload using the selection dialog box.
Next you can specify the following options to use with the upload of the data mapping
configuration:
l Named - allow this configuration to be identified/referenced by its Managed File Name as
well as its Managed File ID
l Persistent - make this configuration persistent in the file store
Page 90
files are uploaded to the file store under the same name, then only the most recently
uploaded file will be associated with (or can be referenced using) that name.
Once the configuration and options are selected, simply select the Submit button to upload the
configuration to the server's file store and the resulting Managed File ID for the data mapping
configuration will be returned and displayed to the Results area.
Discussion
Firstly, we define an event handler that will run in response to the submission of the HTML form
via the selection of the Submit button.
When our event handler function is called, we then obtain a reference to the local data mapping
configuration previously selected. This is achieved by getting the first value of the files
attribute of the HTML element with the ID of datamapper (in this case a file type input HTML
element) and storing it in a variable file.
We also obtain boolean values for the Named and Persistent options (both checkbox type
input HTML elements) and store them in the named and persistent variables respectively.
Next we construct a jQuery AJAX request which will be sent to the File Store REST service.
We use an object called settings to hold the arguments for our request:
Method type and url arguments are specified as shown earlier, with the addition of a
persistent query parameter which specifies whether the configuration is to be persistent in
the file store when uploaded.
We specify the variable file as the data or contents of the request, a contentType argument
of "application/octet-stream", and because we are sending file data we also specify a
processData argument set to false.
If the Named option is checked in our form, and the named variable is true, then a filename
query parameter is also added which contains the file name of the configuration selected
(file.name).
Page 91
Lastly, the settings object is passed as an argument to the jQuery AJAX function ajax and the
request is executed.
When the request is successful or done, a request response is received and the content of that
response is passed as the function parameter response. In the example, we then display the
value of this parameter which should be the new Managed File ID of the data mapping
configuration in the file store.
Further Reading
See the File Store Service page of the REST API Reference section for further detail.
Page 92
Uploading a Design Template to the File Store
Problem
You want to upload a design template to the File Store so that it can be used as part of a
Content Creation operation.
Solution
The solution is to create a request using the following URI and method type to submit the
design template to the server via the File Store REST service:
Only one Managed File in the file store can be associated with a specific name. If two
files are uploaded to the file store under the same name, then only the most recently
Usage
To run the example simply select the Browse button and then select the design template you
wish to upload using the selection dialog box.
Next you can specify the following options to use with the upload of the design template:
l Named - allow this template to be identified/referenced by its Managed File Name as well
as its Managed File ID
l Persistent - make this template persistent in the file store
Page 96
uploaded file will be associated with (or can be referenced using) that name.
Once the template and options are selected, simply select the Submit button to upload the
template to the server's file store and the resulting Managed File ID for the design template will
be returned and displayed to the Results area.
Discussion
Firstly, we define an event handler that will run in response to the submission of the HTML form
via the selection of the Submit button.
When our event handler function is called, we then obtain a reference to the local design
template previously selected. This is achieved by getting the first value of the files attribute of
the HTML element with the ID of designtemplate (in this case a file type input HTML element)
and storing it in a variable file.
We also obtain boolean values for the Named and Persistent options (both checkbox type
input HTML elements) and store them in the named and persistent variables respectively.
Next we construct a jQuery AJAX request which will be sent to the File Store REST service.
We use an object called settings to hold the arguments for our request:
Method type and url arguments are specified as shown earlier, with the addition of a
persistent query parameter which specifies whether the template is to be persistent in the
file store when uploaded.
We specify the variable file as the data or contents of the request, a contentType argument
of "application/zip", and because we are sending file data we also specify a processData
argument set to false.
If the Named option is checked in our form, and the named variable is true, then a filename
query parameter is also added which contains the file name of the template selected
(file.name).
Lastly, the settings object is passed as an argument to the jQuery AJAX function ajax and the
request is executed.
Page 97
When the request is successful or done, a request response is received and the content of that
response is passed as the function parameter response. In the example, we then display the
value of this parameter which should be the new Managed File ID of the design template in the
file store.
Further Reading
See the File Store Service page of the REST API Reference section for further detail.
Page 98
Uploading a Job Creation Preset to the File Store
Problem
You want to upload a job creation preset to the File Store so that it can be used as part of a Job
Creation operation.
Solution
The solution is to create a request using the following URI and method type to submit the job
creation preset to the server via the File Store REST service: