Through the Tenant API, an attachment can be uploaded and associated to an Order. There are two ways to do this:
- Azure Storage SKD
- Microsoft REST API (blobServiceRestApiUr).
This article explains how to use the Microsoft REST API
Note that Basic Authentication is required for all requests as such, make sure to provide the Authorization header with a valid value.
1) Generate storage access:
Review: https://api.dispatchscience.com/reference/get_api-v1-orders-orderid-attachments-getcreateaccess
The query parameter AttachmentId must be a GUID or be left blank and it will be provided.
This will return the following information:
{
"orderId": "...",
"attachmentId": "...",
"attachmentUrl": "...",
"attachmentSas": "...",
"blobServiceRestApiUrl": "..."
}
Because we are using Microsoft API, the only information we need is returned in "blobServiceRestApiUrl" and the "attachmentId".
2) Upload the file to storage:
Review https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=microsoft-entra-id
- Make a http PUT request to the blobServiceRestApiUrl returned in step 1.
- Authentication will be none.
- Send the header “x-ms-blob-type: BlockBlob”. If you are uploading a pdf, add also "Content-Type: application/pdf"
or
- Send the file to upload in the request body (this needs to be a byte array):
3) You can then associate the uploaded file to the Order by using attachmentId from step 1, the Order Id and additional options using POST/api
note: note associated to the file
includeWithInvoice can be set to true or false
visibleForDriver can be set to true of false
type:
- 0: order attachment
- 1: delivery attachment
- 3: pickup attachment
- 4: additional signature
workflowStepId: guid representing the workflow step
filename: name of the file including the extension
{
"attachmentId": "string",
"note": "string",
"includeWithInvoice": true,
"visibleForDriver": true,
"type": 0,
"typeId": "string",
"workflowStepId": "string",
"fileName": "string"
}
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article