Newer Version Available
Upload Binary Files
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.
There are two ways to upload a binary file in request.
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.
1curl -v -H 'Authorization: Bearer 00Dxx0000001gER!ARoAQFFeB_55d8B3Sh....'
2 -F 'json={"apiName": "ContentNote","fields": {"Title": "My List of Things"}};type=application/json'
3 -F 'Content=@note.txt;type=application/octet-stream'
4 -X POST 'http://{instance-name}.salesforce.com/services/data/v59.0/ui-api/records'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.
1{
2"apiName": "ContentNote",
3"fields": {
4 "Content": "SGksIFRoaXMgaXMgYmFzZTY0",
5 "Title": "Sample Title"
6 }
7}1curl -X POST -H 'Authorization: Bearer 00Dxx0000001gER!ARoAQFFeB_55d8B3Sh...'
2 -H 'Content-Type: application/json' -H "Content-type: application/json"
3 -d '{"apiName": "ContentNote","fields": {"Content": "SGksIFRoaXMgaXMgYmFzZTY0","Title": "Sample Title"} }'
4 'http://{instance-name}.salesforce.com/services/data/v59.0/ui-api/records'