Content:
1. How to Set Up File Upload Using API v2?
1.1 API Credentials
1.2 Implementation
2. How to Set Up File Download Using API v2?
2.1 API Credentials
2.2 Implementation
Certain integration scenarios may require file uploads to or downloads from Businessmap. For that purpose, we have included a file upload and download functionality in our API v2. Please check out our dedicated article for more details about the API v2. If you still have some questions after reading this article, please do not hesitate to contact our Support team at support@businessmap.io.
1. How to Set Up File Upload Using API v2?
Uploading files through the Businessmap API needs to be performed in 2 steps. The first step is uploading a file to the server, and the second step is to link that file to a card or initiative. In this article, we will explore how to perform both steps and any particularities about the process.
API Credentials
As with the rest of the API, the file upload functionality requires authorization with a Businessmap API Key. You can retrieve your API key by navigating to the My Account menu (top right corner) and switching to the API tab.
Implementation
Step 1. To upload a file, you need to execute a POST request to this endpoint — https://{subdomain}.kanbanize.com/api/v2/files — where {subdomain} is the subdomain of your account.
There are two ways to send the file contents. The first option is to set the JSON body of the request. This upload accepts only base64 encoded strings and it needs to set two object properties: “file_name” and “content,” as such:
Binary file upload is when you send a multipart/form-data body, with the “filename” and “file” parameters, like this:
The response of the POST request is a JSON body, which contains the file name and a link to that file.
Step 2. Once the file has been uploaded to the server, a link needs to be created between the file and the card. To create the link, you need to execute a PATCH request to this endpoint —
https://{subdomain}.kanbanize.com/api/v2/cards/{card_id} — where {subdomain} is the subdomain of your account, and {card_id} is the internal id of the card to which the attachment will be linked.
The body of the request needs to be in JSON format, containing an array type object with a key “attachments_to_add” and items having “file_name” and “link” properties (the ones you have received from the upload).
Note: Multiple files may be linked to a card simultaneously by adding them to the “attachments_to_add” array object.
2. How to Set Up File Download Using API v2?
Downloading files through the Businessmap API needs to be performed in 2 steps. The first step is obtaining the link for the file from the card, and the second step is to download that file as binary data or a base64 encoded text. Below we will explore how to perform both steps and any particularities associated with the process.
API Credentials
File download, as the rest of the API calls, requires authorization with a Businessmap API Key. You can retrieve your API key by navigating to the My Account menu (top right corner) and switching to the API tab.
Implementation
Step 1. The first part is executing a GET request to this endpoint — https://{subdomain}.kanbanize.com/api/v2/cards/{card_id}/attachments — where {subdomain} is the subdomain of your account, and {card_id} is the internal id of the card where the attachment will be uploaded.
The response of the GET request is a JSON array object, which contains a list of attachments for the card, along with their ID, file name, link, and position.
Step 2. Once the link to the file has been obtained, you can download the file. To do that, you need to execute a GET request to this endpoint — https://{subdomain}.kanbanize.com/api/v2/files/download
Add the query parameter “link” which is set to be the link to the file you want to download.
Note: Postman automatically renders the image.
Alternatively, you can obtain the file content as a base64 encoded text, by adding another query parameter “encoding” with a value set to “base64.”
The base64 encoded text can be used to upload files to another Businessmap card directly. See section 1.