Sending a Binary File Using an API Call Notification

This guide will help you send a file using an API Call Notification.

Requirements

This is an advanced tutorial. To follow it, you should be familiar with basic platformOS concepts, HTML, Liquid, APIs and Form Configurations, and the topics in the Get Started section, especially tutorials related to Notifications.

Steps

Sending a binary file using an API Call Notification is a special case of creating a regular API Call Notification as described in Get Started: Creating an API Call Notification. This tutorial describes the difference between a regular request and sending a file, so it consists of only one step.

  1. Create API Call Notification

Step 1: Create API Call Notification

Create the API Call Notification notifications/api_call_notifications/send_file.liquid:

---
name: send_file
to: 'https://example.com/endpoint'
delay: 0
enabled: true
format: http
trigger_condition: true
request_type: post_multipart
---
{
  "file": {
    "url": "https://domain.com/my-file.jpg",
    "name": "my-file.jpg",
    "content_type": "image/jpeg"
  },
  "file2": {
    "url": "https://domain.com/other-file.jpg",
    "name": "other-file.jpg",
    "content_type": "image/jpeg"
  }
}

This defines a POST request to the endpoint, which would send two binary files. The main difference between a regular API call and sending a binary file is the _multipart suffix in request type. Valid request types are post_multipart, patch_multipart and put_multipart. The required body format for *_multipart requests is JSON following structure:

{
  "<param name>": {
    "url": "<required url to file remote location>",
    "name": "<optional file name>",
    "content_type": "<optional content type>"
  }
}

Warning
If url includes special characters, for example & [which is the case for custom_attachment.url] please make sure to use the html_safe filter.

Questions?

We are always happy to help with any questions you may have.