Repository navigation
Printing
| Endpoint | /printers |
| Formats | XML, JSON |
| Authentication required? | Yes |
| Sender ID required? | No |
| Requires DirectPrint physically connected to thermal printer(s) | No |
cURL
curl -g -XGET -H'X-Cargonizer-Key: 12345' 'https://api.cargonizer.no/printers.json'HTTP
GET /printers.json HTTP/1.1
Host: cargonizer.no
X-Cargonizer-Key: 12345
Pseudocode
http = new HTTPRequest();
http.method = 'GET';
http.url = 'https://api.cargonizer.no/printers.json';
http.headers.add('X-Cargonizer-Key', '12345');
response = http.execute();
| Endpoint | /consignments/label_direct |
| Formats | XML, JSON |
| Authentication required? | Yes |
| Sender ID required? | Yes |
| Requires DirectPrint physically connected to thermal printer(s) | Yes |
This endpoint will create a job to physically print labels on the appropriate DirectPrint connected printer.
Note: If you plan to print in bulk, you must make one single call and enter the identifiers as an array. Then you will have a guarantee for a single print job where the labels come out in the same order. Do not print one label at a time as you may get the order wrong and labels (print jobs) may disappear.
cURL
curl -g -XPOST -H'X-Cargonizer-Key: 12345' -H'X-Cargonizer-Sender: 678' 'https://api.cargonizer.no/consignments/label_direct?printer_id=123&consignment_ids[]=1&consignment_ids[]=2&piece_ids[]=3&piece_ids[]=4'HTTP
POST /consignments/label_direct?printer_id=123&consignment_ids[]=1&consignment_ids[]=2&piece_ids[]=3&piece_ids[]=4 HTTP/1.1
Host: cargonizer.no
X-Cargonizer-Key: 12345 X-Cargonizer-Sender: 678
Pseudocode
http = new HTTPRequest();
http.method = 'POST';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('X-Cargonizer-Sender: 678');
http.url = 'https://api.cargonizer.no/consignments/label_direct?printer_id=123&consignment_ids[]=1&consignment_ids[]=2&piece_ids[]=3&piece_ids[]=4';
http.queryStringParameters.set('printer_id', '123');
http.queryStringParameters.set('consignment_ids[]', '1');
http.queryStringParameters.set('consignment_ids[]', '2');
http.queryStringParameters.set('piece_ids[]', '3');
http.queryStringParameters.set('piece_ids[]', '4');
response = http.execute();
| Endpoint | /consignments/label_pdf |
| Response format | |
| Authentication required? | Yes |
| Sender ID required? | Yes |
cURL
curl -g -XGET -H'X-Cargonizer-Key: 12345' -H'X-Cargonizer-Sender: 678' 'https://api.cargonizer.no/consignments/label_pdf?consignment_ids[]=1&consignment_ids[]=2&piece_ids[]=3&piece_ids[]=4'HTTP
GET /consignments/label_pdf?consignment_ids[]=1&consignment_ids[]=2&piece_ids[]=3&piece_ids[]=4 HTTP/1.1
Host: cargonizer.no
X-Cargonizer-Key: 12345
X-Cargonizer-Sender: 678
Pseudocode
http = new HTTPRequest();
http.method = 'GET';
http.url = 'https://api.cargonizer.no/consignments/label_pdf?consignment_ids[]=1&consignment_ids[]=2&piece_ids[]=3&piece_ids[]=4';
http.queryStringParameters.set('consignment_ids[]', '1');
http.queryStringParameters.set('consignment_ids[]', '2');
http.queryStringParameters.set('piece_ids[]', '3');
http.queryStringParameters.set('piece_ids[]', '4');
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('X-Cargonizer-Sender', '678');
response = http.execute();
| Endpoint | /waybill_pdf |
| Formats | |
| Authentication required? | Yes |
| Sender ID required? | Yes |
cURL
curl -g -XGET -H'X-Cargonizer-Key: 12345' -H'X-Cargonizer-Sender: 678' 'https://api.cargonizer.no/consignments/waybill_pdf?consignment_ids[]=1&consignment_ids[]=2'HTTP
GET /consignments/waybill_pdf?consignment_ids[]=1&consignment_ids[]=2 HTTP/1.1
Host: cargonizer.no
X-Cargonizer-Key: 12345
X-Cargonizer-Sender: 678
Pseudocode
http = new HTTPRequest();
http.method = 'GET';
http.url = 'https://api.cargonizer.no/consignments/waybill_pdf?consignment_ids[]=1&consignment_ids[]=2';
http.queryStringParameters.set('consignment_ids[]', '1');
http.queryStringParameters.set('consignment_ids[]', '2');
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('X-Cargonizer-Sender', '678');
response = http.execute();
| Endpoint | /goods_declaration_pdf |
| Formats | |
| Authentication required? | Yes |
| Sender ID required? | Yes |
cURL
curl -g -XGET -H'X-Cargonizer-Key: 12345' -H'X-Cargonizer-Sender: 678' 'https://api.cargonizer.no/consignments/goods_declaration_pdf?consignment_ids[]=1&consignment_ids[]=2'HTTP
GET /consignments/goods_declaration_pdf?consignment_ids[]=1&consignment_ids[]=2 HTTP/1.1
Host: cargonizer.no
X-Cargonizer-Key: 12345
X-Cargonizer-Sender: 678
Pseudocode
http = new HTTPRequest();
http.method = 'GET';
http.url = 'https://api.cargonizer.no/consignments/goods_declaration_pdf?consignment_ids[]=1&consignment_ids[]=2';
http.queryStringParameters.set('consignment_ids[]', '1');
http.queryStringParameters.set('consignment_ids[]', '2');
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('X-Cargonizer-Sender', '678');
response = http.execute();
| Endpoint | /prints |
| Formats | JSON,PDF,ZPL,EPL |
| Authentication required? | Yes |
| Sender ID required? | No |
| Requires DirectPrint physically connected to thermal printer(s) | Yes |
Parameters are typically supplied using a JSON payload, or a combination of HTTP query string and body with the associated Content-Type header.
Required/allowed parameters visualized in a normalized format:
{
print: {
printer: {
id: Integer
},
data: {
type: String['application/pdf' | 'application/x.zpl' | 'application/x.epl']
encoding: ?String['base64']
content: String
}
}
}
-
print.data.typeindicates the type of the content, which is either PDF or ZPL/EPL depending on the printer. -
print.data.encodingis not required, but may be "base64" to indicate content is Base64 encoded.
A JSON payload will typically look like this:
{
"print": {
"printer": {"id": 12345},
"data": {
"type": "application/pdf",
"encoding": "base64",
"content": "<base64 encoded PDF goes here>"
}
}
}encoding is necessarily "base64" with binary data, which can't be represented direcly in JSON:
curl \
-XPOST \
-H'X-Cargonizer-Key: 12345' \
-H'Content-Type: application/json' \
-H'Accept: application/json' \
--data-binary '{"print": {"printer": {"id": 123}, "data": {"type": "application/x.zpl", "encoding": "base64", "content": "XlhBXkZPNTAsNjBeQTAsMjAwXkZESGVsbG9eRlNeRk81MCwzMDBeQTAsMjAwXkZEV29ybGReRlNeWFoK"}}}' \
'https://api.cargonizer.no/prints'http = new HTTPRequest();
http.method = 'POST';
http.url = 'https://api.cargonizer.no/prints';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('Content-Type', 'application/json');
http.headers.add('Accept', 'application/json');
http.body = EncodeJSON({
print: {
printer: {id: 123},
data: {
type: "application/x.zpl",
encoding: "base64",
content: EncodeBase64("^XA^FO50,60^A0,200^FDHello^FS^FO50,300^A0,200^FDWorld^FS^XZ")
}
}
});
response = http.execute();
But it can be omitted if the data is a valid JSON string:
curl \
-XPOST \
-H'X-Cargonizer-Key: 12345' \
-H'Content-Type: application/json' \
-H'Accept: application/json' \
--data-binary '{"print": {"printer": {"id": 123}, "data": {"type": "application/x.zpl", "content": "^XA^FO50,60^A0,200^FDHello^FS^FO50,300^A0,200^FDWorld^FS^XZ"}}}' \
'https://api.cargonizer.no/prints'http = new HTTPRequest();
http.method = 'POST';
http.url = 'https://api.cargonizer.no/prints';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('Content-Type', 'application/json');
http.headers.add('Accept', 'application/json');
http.body = EncodeJSON({
print: {
printer: {id: 123},
data: {
type: "application/x.zpl",
content: "^XA^FO50,60^A0,200^FDHello^FS^FO50,300^A0,200^FDWorld^FS^XZ"
}
}
});
response = http.execute();
Content to be printed can be provided directly in HTTP body by setting the Content-Type header appropriately. The value of the header is the type of content to be printed with an optional header param specifying Base64 encoding.
Raw ZPL:
curl -XPOST \
--data-binary '^XA^FO50,60^A0,200^FDHello^FS^FO50,300^A0,200^FDWorld^FS^XZ' \
-H'X-Cargonizer-Key: 12345' \
-H'Content-Type: application/x.zpl' \
-H'Accept: application/json' \
'https://api.cargonizer.no/prints?print[printer][id]=12345'http = new HTTPRequest();
http.method = 'POST';
http.url = 'https://api.cargonizer.no/prints';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('Content-Type', 'application/x.zpl');
http.headers.add('Accept', 'application/json');
http.parameters.add('print[printer][id]', '123');
http.body = "^XA^FO50,60^A0,200^FDHello^FS^FO50,300^A0,200^FDWorld^FS^XZ";
response = http.execute();
Base64 encoded ZPL:
curl \
-XPOST \
--data-binary 'XlhBXkZPNTAsNjBeQTAsMjAwXkZESGVsbG9eRlNeRk81MCwzMDBeQTAsMjAwXkZEV29ybGReRlNeWFoK' \
-H'X-Cargonizer-Key: 12345' \
-H'Content-Type: application/x.zpl;encoding=base64' \
-H'Accept: application/json' \
'https://api.cargonizer.no/prints?print[printer][id]=12345'http = new HTTPRequest();
http.method = 'POST';
http.url = 'https://api.cargonizer.no/prints';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('Content-Type', 'application/x.zpl;encoding=base64');
http.headers.add('Accept', 'application/json');
http.parameters.add('print[printer][id]', '123');
http.body = Base64Encode("^XA^FO50,60^A0,200^FDHello^FS^FO50,300^A0,200^FDWorld^FS^XZ");
response = http.execute();
Base64 encoded PDF body:
POST /prints
X-Cargonizer-Key: 12345
Content-Type: application/pdf;encoding=base64
Accept: application/json
JVBERi0xLjEKJcKlwrHDqwoKMSAwIG9iagogIDw8IC9UeXBlIC9DYXRhbG9nCiAgICAgL1BhZ2Vz
IDIgMCBSCiAgPj4KZW5kb2JqCgoyIDAgb2JqCiAgPDwgL1R5cGUgL1BhZ2VzCiAgICAgL0tpZHMg
WzMgMCBSXQogICAgIC9Db3VudCAxCiAgICAgL01lZGlhQm94IFswIDAgMjg5LjEzNCA1NDQuMjUy
XQogID4+CmVuZG9iagoKMyAwIG9iagogIDw8ICAvVHlwZSAvUGFnZQogICAgICAvUGFyZW50IDIg
MCBSCiAgICAgIC9SZXNvdXJjZXMKICAgICAgIDw8IC9Gb250CiAgICAgICAgICAgPDwgL0YxCiAg
ICAgICAgICAgICAgIDw8IC9UeXBlIC9Gb250CiAgICAgICAgICAgICAgICAgIC9TdWJ0eXBlIC9U
eXBlMQogICAgICAgICAgICAgICAgICAvQmFzZUZvbnQgL1RpbWVzLVJvbWFuCiAgICAgICAgICAg
ICAgID4+CiAgICAgICAgICAgPj4KICAgICAgID4+CiAgICAgIC9Db250ZW50cyA0IDAgUgogID4+
CmVuZG9iagoKNCAwIG9iagogIDw8IC9MZW5ndGggNTggPj4Kc3RyZWFtCiAgQlQKICAgIC9GMSAy
OCBUZgogICAgNTAgNTAwIFRkCiAgICAoSGVsbG8gV29ybGQpIFRqCiAgRVQKZW5kc3RyZWFtCmVu
ZG9iagoKeHJlZgowIDUKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDE4IDAwMDAwIG4gCjAw
MDAwMDAwNzcgMDAwMDAgbiAKMDAwMDAwMDE3OCAwMDAwMCBuIAowMDAwMDAwNDU3IDAwMDAwIG4g
CnRyYWlsZXIKICA8PCAgL1Jvb3QgMSAwIFIKICAgICAgL1NpemUgNQogID4+CnN0YXJ0eHJlZgo1
NjUKJSVFT0YKhttp = new HTTPRequest();
http.method = 'POST';
http.url = 'https://api.cargonizer.no/prints';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('Content-Type', 'application/pdf;encoding=base64');
http.headers.add('Accept', 'application/json');
http.parameters.add('print[printer][id]', '123');
http.body = Base64Encode(ReadFile('filename.pdf'));
response = http.execute();
Raw PDF body:
http = new HTTPRequest();
http.method = 'POST';
http.url = 'https://api.cargonizer.no/prints';
http.headers.add('X-Cargonizer-Key', '12345');
http.headers.add('Content-Type', 'application/pdf');
http.headers.add('Accept', 'application/json');
http.parameters.add('print[printer][id]', '123');
http.body = ReadFile('filename.pdf');
response = http.execute();