/
Creating Chatter Records with an Attachment
Creating Chatter Records with an Attachment
Creating a Chatter record with an attachment add the attachment to the Chatter record rather than the using the conventional Attachment record as outlined here. Also, the byte array for the attachment must be converted to a base 64 string for the ContentData field of the FeedItem.
GenericSalesforceEntity feedItem = new GenericSalesforceEntity("FeedItem"); //The ParentId is the ID of the sObject that the Feed Item is attached to. In this case it is a Contact ID. contactFeed.InternalFields.SetField("ParentId", "0039000000Msoqj"); contactFeed.InternalFields.SetField("Body", "Some chatter text"); //Attach a file byte[] bytes = System.IO.File.ReadAllBytes("MyPDF.pdf"); contactFeed.InternalFields.SetField("ContentData", Convert.ToBase64String(fileChatter.FileBytes)); contactFeed.InternalFields.SetField("MyPDF.pdf ", fileChatter.FileName); GenericSalesforceService chatterContactService = new GenericSalesforceService(GetSalesforceSession, "FeedItem"); SaveResult saveResult = chatterContactService.Insert(feedItem);
Related content
Creating Chatter Records
Creating Chatter Records
More like this
Adding Attachments to a Salesforce Record
Adding Attachments to a Salesforce Record
More like this
Attaching Files to a Salesforce Record
Attaching Files to a Salesforce Record
More like this
Upload Files to Salesforce Documents
Upload Files to Salesforce Documents
More like this
Download Files from Salesforce Attachments
Download Files from Salesforce Attachments
More like this
File Uploads
File Uploads
More like this