function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tim STim S 

Add attachment to a Custom Object Record using API

Hello,

I'm using the REST API and I would like to use it to add attachments to a record in a Custom Object.  The attachments may be binary (eg jpeg, pdf and similar) or text files.

Is this possible?  I can see a way to create a document but I can't see how to then attach it to a record.

Cheers

Tim
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Tim,

You can use attachment object to insert into attachment.
client.create('Attachment', ParentId: 'RecordIdOfparent',
                      Description: 'Document test',
                      Name: 'My image',
                      Body: Restforce::UploadIO.new(File.expand_path('image.jpg', __FILE__), 'image/jpeg')
Hope it will be helpful.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Thanks
Rahul Kumar