How to Create a Ticket with an Attachment via API in Power Automate
This article explains how to create a ticket with file attachments in BoldDesk using the REST API within Microsoft Power Automate. The process involves uploading the file, retrieving the attachment token, and then using that token when creating the ticket.
Prerequisites
Before you begin, ensure that you have:
- A BoldDesk account with API access.
- A valid API key.
- A Power Automate flow.
- The file content available in Power Automate.
- Permission to create tickets through the REST API.
Workflow Overview
The following flow demonstrates the complete process of creating a ticket with an attachment:
1. Retrieve the File Content
Obtain the file content that will be uploaded as an attachment.
2. Initialize a Variable
Create a variable to store the attachment token returned by the upload API response.
3. Upload the File Using the API
Use the Upload Attachment API to upload the file and generate an attachment token.
Request Payload
Payload JSON Format
{
"$content-type": "multipart/form-data",
"$multipart": [
{
"body": "**File-Content_in_Bytes**",
"headers": {
"Content-Disposition": "form-data; name=\"uploadFiles\"; filename= **File_name**"
}
}
]
}
4. Parse the Upload Response
After the file is uploaded successfully, parse the API response to retrieve the attachment token.
Schema
{
"type": "object",
"properties": {
"token": {
"type": "string"
},
"url": {
"type": "string"
}
}
}
5. Store the Attachment Token
Assign the value from the token property to the previously initialized variable.
The attachment token is required when creating the ticket.
6. Create the Ticket
Use the Create Ticket API and include the attachment token in the request body to associate the uploaded file with the ticket.
Frequently Asked Questions
-
Why do I need to upload the file before creating the ticket?
BoldDesk requires attachments to be uploaded first. The upload API returns an attachment token, which must be included in the ticket creation request. -
What is the attachment token?
The attachment token is a temporary identifier returned by the Upload Attachment API. It links the uploaded file to the ticket when the ticket is created. -
Can I attach multiple files to a ticket?
Yes. Upload each file separately, collect the returned attachment tokens, and include all tokens in the Create Ticket API request. -
What happens if the upload request fails?
If the upload fails, no attachment token is generated, and the file cannot be associated with the ticket. Verify the API endpoint, authentication credentials, and file content before retrying.