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
Neeraj GuptaNeeraj Gupta 

Chatter File upload through REST Client throwing "Binary data included but file attachment information is missing. If providing rich JSON/XML input in multipart REST, make sure to include Content-Type header in the part."

 I am using below request through chrome advance rest client plugin to upload a chatter with file content and getting exception as 

Error Message: 
[{"errorCode":"POST_BODY_PARSE_ERROR","message":"Binary data included but file attachment information is missing. If providing rich JSON/XML input in multipart REST, make sure to include Content-Type header in the part."}]


Status
400 Bad Request Show explanation Loading time: 1096
Request headers
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
Authorization: OAuth 00Do0000000Hb0Q!ARkAQPLN0mHGN0vx_id5xe20TIdWilHpKNKxI8luXDURBCpLN8IFam_ga1F8Mok_o6LNQCgB.5ah8WyKng.P1ZmLRbu5oRzo
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary3n9vu9ZOkCPW4HAw
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: com.salesforce.LocaleInfo=us; oinfo="c3RhdHVzPURFTU8mdHlwZT0yJm9pZD0wMERmMDAwMDAwM2JITEE="; __cfduid=d5fc50ea917b08b8c4d0764c74aa205f61406140518228; lp=%7B%7D; rememberUn=false; embeddedcomponentcalloutcookie=1; BrowserId=BGaoKzO_QBiyAUpoxbU4pA; sfdc_lv2="KxG83HH39SqZku5nmKjkn2et470V3EswpF2TXsmahbl+KXqI1ci8bAID2HZQURCd49nuW7Y1r+pgcF7XxnqzN/xDgjldeJfFPINSl98L9k6O51HsltQSs4idzitW34OI2IUyF+Sj9F/R6DzQVwRQQvSbGXqF+UlY6Q5O1X8Z9LvKUozVfFBhgyYRdDNYgLeC/N2XjgfIUCnwYQ7Nsc/9AwBnpZzbwmyPhvsrbj8AW419Cm6JPpBDNFKZzBJFuFvHYvKXC7BnmQ7SlA1qjLTSOqq+k7uIROp2NKVtgi5MiNVFYSiNq+FccmlLC/a2UHlouL2eBOfIFWoDv5kgC/7nRUHI3vi9bKN4KuslHYszr/cDQLuiTyAD3wTSiY1/HKo48uhmn91unD4zjBM89OrhxVLevL8gyCWN5tUsmfcx9GxguChep5cz3/Thc9r5AQwOR9dogxIFrpDMsF9dG3mUIPzicf4zal3hTVNW3xz5y6HYhUVkcw//VmSI7i8ggR98U="; disco=o:00Do0000000Hb0Q:005o0000000HzDo:0; autocomplete=1; sid=00Do0000000Hb0Q!ARkAQPLN0mHGN0vx_id5xe20TIdWilHpKNKxI8luXDURBCpLN8IFam_ga1F8Mok_o6LNQCgB.5ah8WyKng.P1ZmLRbu5oRzo; sid_Client=0000000HzDo0000000Hb0Q; clientSrc=59.89.147.242; inst=APPo; oid=00Do0000000Hb0Q; setupopen=; JSESSIONID=7ow2vu2764kwr33z8gabnyc7; lastlist="/a09?fcf=00Bo0000000U2zz&rolodexIndex=-1&page=1"; webact=%7B%22l_vdays%22%3A1%2C%22l_visit%22%3A1408984740028%2C%22session%22%3A1408989139956%2C%22l_search%22%3A%22%22%2C%22l_dtype%22%3A%22%22%2C%22l_page%22%3A%22SFDC%3Aen%3Aa0ao0000002h8tu%22%2C%22counter%22%3A22%2C%22pv%22%3A8%2C%22f_visit%22%3A1404841447432%2C%22version%22%3A%22w172.1%22%2C%22d%22%3A%2270130000000sUW0%22%2C%22l_cloud%22%3A%22No%20Cloud%22%2C%22seg%22%3A%22customer%3Aus%22%2C%22customer%22%3A1405964202516%7D; s_sess=%20s_ppv_x%3D%3B%20s_cc%3Dtrue%3B%20s_sq%3D%3B%20s_ppv%3D78%257C0%3B; s_vi=[CS]v1|29DE16F5054892B0-40000100C0008275[CE]
Response headers
Date: Mon, 25 Aug 2014 18:31:44 GMT
Cache-Control: private
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

Below is the request description


POST URL:
https://na17.salesforce.com/services/data/v29.0/chatter/feeds/record/a07o000000097sGAAQ/feed-items

Auth Header
Authorization: OAuth <SESSION_ID>

Request Body
{ 
   "body":
   {
      "messageSegments" : [
      {
         "type" : "Text", 
         "text" : "Please accept this receipt."
      }
      ]
   }, 
   "attachment": 
   {
      "attachmentType" : "NewFile",
      "description": "Receipt for expenses",
      "title" : "a.png"
   },
   "feedElementType" :"FeedItem",
   "subjectId" : "005o0000000HzDo"
}

Uploading an image file with name as "feedItemFileUpload".

This looks like a common problem. I am able to post chatter with links and all but not working only in case of files. Thanks for help in advance.

Martijn SchwarzerMartijn Schwarzer
Hi there,

Have you tried to add the header:

Content-Type: application/json;charset=UTF-8

?

Regards,
Martijn Schwärzer
Neeraj GuptaNeeraj Gupta
Thanks for your help MartjinSchwarzer. I tried by changing content type to what you suggested. But still getting same exception..
SonamSonam (Salesforce Developers) 
Hey Neeraj,

Could you please try adding :

Content-Disposition: form-data; name="fileData" to the header  as explained in http://www.salesforce.com/us/developer/docs/chatterapi/Content/intro_input.htm as a required parameter

Also, go through the following code snippet where user is trying the same using REST API:
http://salesforce.stackexchange.com/questions/24671/upload-files-to-a-case-in-salesforce-via-rest-api