Document Content Upload and Download

Document resources can be created and exist independent of any other data. Some documents can also be associated with many other resource types, e.g. shipments, order releases etc. CRUD for all documents is available via the Document root resource.

In addition, when documents are associated with other resource types, the associated root resources provide access to these associated document resources via their own corresponding "documents" child resource.

The Document resource supports custom actions for upload and download of document content (see Custom Actions for a general description of actions). In addition, each root resource type which supports Document child resources may support an upload action: Add Document To Object.

Download Content

Access to the actual document content for download, is available via the "contents" child resource of the "documents" root resource. The child resource will contain a "canonical" link reference where the content can be downloaded using an HTTP GET. This will return the content according to the media type stored with the document definition. For example, the following shows the link available to download the content associated with document GID "MY_DOC_GID1":
GET /logisticsRestApi/resources/v2/documents/GUEST.MY_DOC_GID1/contents
{
 "documentContentGid": "GUEST.MY_DOC_CONTENT1",
 "isAwaitingVirusCheck" : false,
 "links" : [
     {
        "rel" : "canonical",
        "href" : "https://server.com/logisticsRestApi/resources/v2/custom-actions/download/ documents/GUEST.MY_DOC_GID1/contents/GUEST.MY_DOC_CONTENT1"
     },
     {
        "rel" : "self",
        "href" : "https://server.com/logisticsRestApi/resources/v2/documents/GUEST.MY_DOC_GID1/contents/GUEST.MY_DOC_CONTENT1"
     }
   ]
}

Upload Content

Upload of document content can be achieved in one of two ways, depending on whether, or not, the document is associated with a business object and whether, or not, that resource type supports the additional action:
  • "upload" custom action for Document resource.
  • "uploadDocument" custom action for each supported business object resource.

Upload

There is an "upload" custom action available to create and attach the content to an existing documents resource. There can currently be only one document content created for an existing document.

Note:

The document content GID cannot be specified for the upload action and so this will value currently default to the same value as the document GID.

The Content-Type header for the HTTP POST must match the type of content being uploaded. This content will be scanned for viruses and the content verified to match the specified type. Any failures will cause the message to be rejected with an HTTP 415: INVALID METHOD error.

The above message will require the following to be true to be successfully created:
  • The document GUEST.MY_DOC_GID must exist.
  • The media type for the document must either be null or be image/png.
  • The document must not have any document content currently associated with it.
  • The content must be a valid PNG document.
For example:
POST /logisticsRestApi/resources/v2/custom-actions/upload/documents/GUEST.MY_DOC_GID1/contents
Content-Type: image/png

... binary content for PNG file

Add Document to Object

Adding a Document to an object directly can be done using the custom action "uploadDocument". This custom action supports adding documents to Shipments and Shipment Stops.

Here is an example of adding documents to Shipments:

POST /logisticsRestApi/resources/v2/custom-actions/uploadDocument/shipments/GUEST.MY_SHIPMENT_GID1?docType=MY_DOC_TYPE&cmsId=MY_CMS_ID
Content-Type: image/png

... binary content for PNG file

This is an example of adding documents to a Shipment Stop:

POST /logisticsRestApi/resources/v2/custom-actions/uploadDocument/shipments/<shipmentGid>/stops/1?docType=MY_DOC_TYPE&cmsId=MY_CMS_ID

Content-Type: image/png

... binary content for PNG file