I need to upload pdfs to some custom objects in SF through the API. Right now I am using restforce in ruby to interact with the API, but I can't seem to figure out how to (neither in restforce nor in the API in general) attach them to the Files or Attachments of the relevant object. It seems like all of the code I see is just to upload to a "Document". Can someone point me in the right direction?
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')
Note that "RecordIdOfparent" is the parentId of salesforce record for which you want to insert the attachment .
Attachments are getting retired and salesforce files are the right object to target .
You can insert data into ContentVersion record
client.create('Document', pathOnClient: '/document.txt', title: 'My image', versionData: Restforce::UploadIO.new(File.expand_path('image.jpg', __FILE__), 'image/jpeg')
Use LinkedEntityId as the salesforce recordId of which you want files to be associated with .