Newer Version Available

This content describes an older version of this product. View Latest

Upload Binary Files

If a record has a Base64 field, you can upload binary data to the field when you create or update a record.

The field determines the binary data file size limit. For example, the ContentNote.Content field has a different limit than the Attachment.Body field. For information about fields, see Standard Objects in Object Reference for Salesforce and Lightning Platform.

Upload Binary Files in a Multipart/Form-Data Request

To upload a binary file, create a multipart request with a part that contains the JSON request body required by the resource, and a part for each file you want to upload. Each file must have its own part. To upload binary data to multiple fields, add a part for each field. The part names must match the field names.

Let’s create a ContentNote record and upload a binary file to its Content field, which is the content or body of the note.

This curl example performs a multi-part request that contains the JSON request body and the binary file.

The first part, starting with -F, contains the JSON request body that the /ui-api/records resource requires. The request body contains the API name of the record (ContentNote) and the title of the record (My List of Things). The part name must be json.

The second part, starting with the second -F, contains the binary file. The part name must match the name of the Base64 field to which the data is uploaded. The ContentNote Base64 field name is Content, and the plain text file we’re uploading is note.txt.

Upload Binary Files in a JSON Request Body

The JSON format doesn’t support binary data. To upload a binary file in a JSON payload, encode the file using Base64 encoding.

In this sample Record Input JSON request body, the Content property contains the file as a Base64 encoded string.

This curl example creates a ContentNote record and uploads the file.