Upload and Associate an Attachment to an Order through Tenant API

Modified on Fri, 4 Oct at 4:02 PM

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"
    A screenshot of a computer screen

Description automatically generated with medium confidence

    or


  • Send the file to upload in the request body (this needs to be a byte array):
    A screenshot of a computer screen

Description automatically generated with medium confidence


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/v1/orders/{orderId}/attachments.

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

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article