You need to sign in to do that
Don't have an account?
Tad Aalgaard 3
Trying to upload a file via RestAPI into Chatter, getting error "Binary data included but file attachment information is missing"
I am getting an error when trying a file into Chatter via RestAPI.
[{"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."}]
Here is a snippet of my code, what am I missing?
[{"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."}]
Here is a snippet of my code, what am I missing?
DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httppost; MultipartEntity reqEntity; httppost = new HttpPost(RES_URL); reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); File imageFile = new File( "/salesforce/wsdl/test.txt"); FileBody bin = new FileBody(imageFile); reqEntity.addPart("feedItemFileUpload", bin); String fileName = "test.txt"; // file name can be text plain only, though using text/html doesn't breaks reqEntity.addPart("fileName", new StringBody(fileName, "text/plain", Charset.defaultCharset())); httppost.setEntity(reqEntity); httppost.setHeader("Authorization", "OAuth " + logon()); String response = EntityUtils.toString(httpclient.execute(httppost) .getEntity(), "UTF-8"); System.out.println(response);
https://developer.salesforce.com/forums/ForumsMain?id=906F00000009APDIA2
http://salesforce.stackexchange.com/questions/36493/uploading-a-file-to-chatter-rest-api