The following API calls allow you to generate labels for allocated consignments, plus customs documents in the event of an overseas consignment: createPaperworkForConsignments, createPaperworkForParcel, createPaperworkForCarton, despatchConsignmentWithBookingCode, and despatchConsignment.
Within each call, you specify parameters
that determine how the paperwork is to be generated (refer to Printing Properties). For example:
<parameters xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/">
<Property>
<propertyName>type</propertyName>
<propertyValue>all</propertyValue>
</Property>
<Property>
<propertyName>format</propertyName>
<propertyValue>pdf</propertyValue>
</Property>
<Property>
<propertyName>dimension</propertyName>
<propertyValue>a4</propertyValue>
</Property>
</parameters>
The results are generated in up to two strings at the bottom of the response: a labels
string containing the label(s) for each parcel, and a documents
string containing the customs documents.
The strings are Base64-encoded, as in the following example, where the strings have been truncated for aesthetic purposes:
<paperwork xsi:type="ns2:Paperwork">
<documents xsi:type="soapenc:base64Binary" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">JVBERi0xL.....JUVPRgo=</documents>
<labels xsi:type="soapenc:base64Binary" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">JVBERi0xL.....RU9GCg==</labels>
</paperwork>
Note
The labels
string should never be empty where allocation has been successful.
A documents
string will only be returned if certain conditions are met, e.g. if the consignment is going via a postal carrier and has a value of 270 GBP
or more, or if the consignment is going via a parcel carrier that does not support paperless trade (refer to Printing Properties),
If the carrier integration supports paperless trade, the documents
string will always be returned empty.
The typical practice is to decode the strings as they are being generated, and print the associated paperwork synchronously at the pack bench. However, to ensure that there are no hold-ups at the pack bench.you do have the option of storing the strings in files and then decoding and printing the documents prior to the consignments arriving at the pack bench, as follows:
Save the Encoded Labels and Customs Documents
If you are happy with the allocation, and you wish to save the paperwork go to the <labels>
and <documents>
at the bottom of the response and:
-
To save the labels, copy the long, encoded string between
<labels>...</labels>
(the above shows only an extract) and paste it into a text file, which you can then save. -
To save the customs documents, copy the long, encoded string between
<documents>...</documents>
(the above shows only an extract) and paste it into a text file, which you can then save.
Decode and Print the Labels and Customs Documents
To decode and print the paperwork once it has been saved:
-
Load the saved
labels
file into a Base64 decoder (e.g. https://www.base64decode.org/). -
Download and save the decoded labels. There will be a label for each parcel in the consignment.
-
Where appropriate, load the saved
documents
file into the Base64 decoder. -
Download and save the decoded customs documents. There will be a customs document for each parcel in the consignment.
Separate Domestic and International Pack Benches
If you have different pack benches for domestic and international consignments, you need to change the Printing Properties accordingly. For example, for domestic consignments, you might save the labels to high quality zpl
format:
<parameters xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/">
<Property>
<propertyName>type</propertyName>
<propertyValue>label</propertyValue>
</Property>
<Property>
<propertyName>format</propertyName>
<propertyValue>zpl</propertyValue>
</Property>
<Property>
<propertyName>dimension</propertyName>
<propertyValue>6x4</propertyValue>
</Property>
<Property>
<propertyName>dpi</propertyName>
<propertyValue>203.8</propertyValue>
</Property>
</parameters>
For international consignments, you would typically save everything to pdf
format, to ensure that both the labels and customs documents are generated in the same call (this is the example shown at the top of the article).