Print Parcel Documents

Print Parcel Documents

Status
Request Type

GET


This feature will dump the raw contents of a PDF file containing one document to the client which can then be saved on your local file system as a PDF; it can then be opened or piped to a printing application depending on your internal workflow.

On this page:

Related:

Endpoint

 https://tms.targetfmi.com/index.php?p=api&c=parcelShipService&m=viewDgDocuments&id=[shipmentId]&type=[documentType]

Request Parameters

ParameterRequired

Available Options/Data Type

Description

[shipmentId]

YesIntegerThe ID of the parcel shipment as returned by the Create a Parcel Shipment API endpoint.
[documentType]Yes
  • OP_900
  • OP_950
  • DANGEROUS_GOODS_SHIPPERS_DECLARATION

The requested document. For Hazmat Ground shipments, a request for each an
OP_900 and an OP_950 will be needed. For Dangerous Goods Express shipments, only 
a request for DANGEROUS_GOODS_SHIPPERS_DECLARATION is required.


Response Parameters

Parameter Name

Description

/messageThe message stack. Refer to the documentation for Making a Request.

Note

On success if the label type is PDF, raw (binary) PDF data is dumped to the client. If an error occurred, you will see a message stack response returned describing the problem.

Example

Full Example for PDF Label

Example
<?php

require_once "../../restClient.class.php";
 
$resource = "https://tms.targetfmi.com/index.php";
$user = "API_KEY";
$pass = "";
$seperator = "?";
 
$rest = new restClient($resource, $user, $pass, $seperator);
 
$shipmentId = 4;
$documentType= 'OP_900';

$endpoint = 'p=api&c=parcelShipService&m=viewDgDocuments&id=' . $shipmentId . '&type=' . $documentType;

$res = $rest->get($endpoint);

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="shipment_' . $shipmentId . '_' . $documentType . '.pdf"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');

echo $res;
 
?>