Show / Hide Table of Contents

JSON Response

The server will respond with a JSON encoded reply, based on the following template:

{
    "jobReady": true|false,
    "mediaTypes": [ "<content media type>" ],
    "deleteMethod": "DELETE"|"GET",
    "clientAction": [ {"request": "<request type>", "options": "<request parameters>"} ],
    "claimBarcodeReader": [ "<device name" ],
    "claimKeyboard": [ "<device name>" ],
    "display": [ { "name": "<device name>", "message": "<message markup>" } ]
}

The server response informs the client of any pending print data, and also allows the server to pass Client Action requests to the client.

  • "jobReady" - if "true" then the server has data for the client which should be printed, it can be retrieved using an http GET request.
  • "mediaTypes" - a list media (MIME) types that available print data may be provided in by the server. For example a server may be able to serve a document as a PNG image, or convert to Star Raster. The client will choose it's preferred format from those available. Note that this can vary between print jobs, for example a server may handle printing bit image and text data types differently.
  • "deleteMethod" - ask the printer to confirm print job completion with either an http DELETE or GET request. This field is optional, and the printer will default to using a DELETE. Generally, supporting DELETE is recommended, as the standard way to remove a resource from a web server. However, some web servers are unable to pass DELETE request to CGI scripts, and so the printer will optionally send an http GET, with specific query string parameter instead.
  • "clientAction" - an array of requests for a special action from the client, see clientAction section.
  • "claimBarcodeReader" - An array of strings, each string is the logical device name of a Barcode Reader device to be claimed for input. Alternatively, a Boolean response of 'true' can be sent to claim the 'default' barcode reader. Claiming a barcode reader means that scanned barcodes will be reported to the server. The claim lasts only until the next poll, therefore the server should set this field every time if it wishes to receive barcode scans continuously.
  • "claimKeyboard" - An array of strings, each string is the logical device name of a Keyboard device to be claimed for input. Alternatively, a Boolean response of 'true' can be sent to claim the 'default' keyboard. Claiming a keyboard means that key presses will be reported to the server. The claim lasts only until the next poll, therefore the server should set this field every time if it wishes to receive keyboard activity continuously.
  • "display" - A string containing a message for the default display, or an array of display messages. Each message should contain two string fields:
    • "name" - the name of the display device to send the message to.
    • "message" - The message to be sent to the display, this can be plain text with CloudPRNT display markup messages, Refer to the Display for details.

To simplify the client<-->server rules, a server should not set a clientAction request and expect printing at the same time. If "jobReady" is set to true, and one or more clientActions are requested, the client will handle the clientAction requests only. It is expected that the printing can wait for the next poll. This does not usually cause any visible performance penalty, because the client will issue the next poll immediately after handling the clientAction requests instead of after the usual polling interval.

Example server POST responses

  • A typical server response, when no printing is required
{
    "jobReady": false
}
  • A typical server response when printing is required, and the server is able to make the job available as either plain text, or png data.
{
    "jobReady": true,
    "mediaTypes": ["text/plain", "image/png"]
}
  • A server response, with request for the printer to report its polling interval and list of supported job encodings
{
    "jobReady": false,
    "clientAction": [
        {"request": "GetPollInterval", "options": ""},
        {"request": "Encodings", "options": ""}
    ]
}
Back to Overview
Back to top