My Question is How we upload file as attachment while posting comment to user using chatter rest api. I have check this in Chatter rest Api Document , and i found following link https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/intro_input.htm#genericBatchExample

Still i am unable to understand that how we test this in WorkBench and PostMan.

This problem is solve by creating own rest Api using Chatter Apex. But How we do this using chatter rest api.

I am unable to understand the below code

POST /services/data/v35.0/chatter/feed-elements HTTP/1.1
Authorization: OAuth 00DRR0000000N0g!...
User-Agent: Jakarta Commons-HttpClient/3.0.1
Host: instance_name
Content-Length: 845
Content-Type: multipart/form-data; boundary=a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
Accept: application/json

Content-Disposition: form-data; name="json"
Content-Type: application/json; charset=UTF-8

            "text":"Please accept this receipt."
         "description":"Receipt for expenses",

Content-Disposition: form-data; name="feedElementFileUpload"; filename="receipt.pdf"
Content-Type: application/octet-stream; charset=ISO-8859-1

...contents of receipt.pdf...


How we deploy this code Using postMan,

Please help it asap.


1 Answer 1


This is not possible since v36.0 of the API:

"In version 36.0 and later, you can’t create a feed post and upload a binary file in the same request. Upload files to Salesforce first, and then use the file IDs to attach one or more files to a feed post."



I was able to perform the call you were looking for:

enter image description here

And here is the "code"

POST /services/data/v35.0/chatter/feed-elements HTTP/1.1
Host: instance.my.salesforce.com
Authorization: Bearer {your session Id}
User-Agent: PostmanRuntime/7.19.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 2f45f01c-b003-4f11-954b-3a892661d5dc,ab2ccf34-f5ec-41d2-9c0e-21c76cfc7b74
Host: instance.my.salesforce.com
Content-Type: multipart/form-data; boundary=--------------------------510963970032964458233422
Accept-Encoding: gzip, deflate
Cookie: BrowserId=tfG6nu95EemUqNWjZ_6GCg
Content-Length: 149463
Connection: keep-alive
cache-control: no-cache

Content-Disposition: form-data; name="feedElementFileUpload"; filename="/C:/Users/bander/Desktop/diff1.txt

Content-Disposition: form-data; name="feedElementFileUpload"; filename="/C:/Users/bander/Desktop/diff1.txt

Content-Disposition: form-data; name="feedElement"

{"body":{"messageSegments":[{"type":"Text","text":"Some Text file."}]},"capabilities":{"content":{"description":"Some Text file","title":"someText.txt"}},"feedElementType":"FeedItem","subjectId":"005f4000000O242"}
  • Thanks Bryan, Its working but it work only on v35 , is it possible we will do it in latest version v47 ?. Oct 31, 2019 at 7:14
  • No, this is not possible because of the first part of my answer Oct 31, 2019 at 11:49
  • I have post new query, could you please help us to resolved it Nov 5, 2019 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .