/
sending-binary-file-using-api-call-notification.liquid
58 lines (48 loc) · 2.24 KB
/
sending-binary-file-using-api-call-notification.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
converter: markdown
metadata:
title: Sending a Binary File Using an API Call Notification
description: This guide will help you send a 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 Forms, and the topics in the Get Started section, especially topics related to Notifications.
* [platformOS Workflow](/developer-guide/platformos-workflow/development-workflow)
* [APIs and Forms](/api-reference/rest-api)
* [Get Started: Creating an API Call Notification](/developer-guide/notifications/creating-api-call-notification)
## 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](/developer-guide/notifications/creating-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
##### app/api_calls/send_file.liquid
```yaml
---
name: send_file
to: 'https://example.com/endpoint'
format: http
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:
```json
{
"<param name>": {
"url": "<required url to file remote location>",
"name": "<optional file name>",
"content_type": "<optional content type>"
}
}
```
{% include 'alert/warning', content: 'If url includes special characters, for example & [which is the case for private uploads] please make sure to use the `html_safe` filter.' %}