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
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" 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 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.
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