File uploads with Call URL actions

Today we are introducing support for file uploads with Call URL actions.

Before, the only way to exchange files with third-party services was to provide them with publicly accessible link to a file. However, not all services are supporting this way of file exchange.

Now, in Call URL actions you can use <%=[File Attachment Column]%> placeholder to refer to file’s content. This extension opens the possibility to integrate with a wide range of cloud storage, document conversion and e-signature services.

An actual code we generate depends on a request body format.

File uploads with text-based body formats

For text-based body formats (XML, JSON, Text) we encode file’s content as base64 string. This is most common way to inject non-text data into larger, otherwise text-based document, JSON structure for example.

Some, but not all APIs that use this encoding are Microsoft Graph API (Mail), SendGrid and DocuSign. To fully describe the file in addition to file’s data these services may require two more parameters: file’s name and file’s media type. To help deal with these, we added two functions: FileName([attachment]) and FileType([attachment]). Both are available only in Call URL action’s body formula context.

Below is a sample setup for Microsoft Graph API – the action sends an email to the email address specified in [To], using [Subject] and [Message] and optionally attaches the file, if specified in [File] column.

File upload in JSON body

Please note the use of conditional expression <%?not IsNull([File]%>. In absence of the file <%=[File]%> construct would generate null, that will likely lead to API error. With conditional expression we can omit whole “attachments” section when there is no file.

Also “name”, “contentType” and “contentBytes” keys in attachment descriptor are no way standard across the APIs. SendGrid API, for example, names these keys as “filename”, “type” and “content” respectively.

File uploads with Form body format

Form body format sends the data just as browser does. In its simple form the payload is a list of key=value pairs separated by & sign. But this way of encoding is limited to text-only data. But once files appear in the payload things are going far more complicated. We’ll save you from all the technical details; simply add key=<%[File Attachment Column]%> and we’ll do the rest properly. API uses form file uploads.

New File body format

File body format is new. When selected we send the content of the file as a request payload. This opens the road for upload integration with multiple cloud storage services, including but not limited to Google Drive, OneDrive and DropBox.

With File body format the formula accepts sole <%=[File Attachment Column]%> and nothing else.

We’ve prepared a sample database that demonstrates file upload capabilities to four cloud storage providers: Google Drive, OneDrive, Dropbox and — feel free to explore.

Happy coding!

2 thoughts on “File uploads with Call URL actions

Leave a Reply

Your email address will not be published. Required fields are marked *