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
mike1051mike1051 

Drag and Drop..upload file into Feeditem content..Please help

HI i am trying to use drag and drop for uploading file into content. Below code works for attachment
sfdcurl = '/services/data/v27.0/sobjects/Attachment/';


When i tried to change it Feeditem object it doesn't work.Please tell me if the url is wrong or anything else i am doing wrong.
sfdcurl = '/services/data/v27.0/sobjects/Feeditem/';

<script>

              var curPopupWindow = [];

            var headersData = {}; 
            headersData["Authorization"] = "Bearer {!$Api.Session_ID}";
            sfdcurl = '/services/data/v27.0/sobjects/Feeditem/';
            Dropzone.autoDiscover = false;
            var myDropzone = new Dropzone("div#dropzone-email-dropable", {
                        maxFiles: 25,
                        url: sfdcurl,
                        addRemoveLinks:true,
                        dictCancelUpload:"Cancel Upload",
                        dictCancelUploadConfirmation:"Are You Sure?",
                        dictRemoveFile:"Remove",
                        parallelUploads:2,
                        filesizeBase:1024,
                        maxFilesize:10,
                        //autoProcessQueue:false,
                        //params: {"ParentId" : "{!contentFolderId}","Description" : "{!sessionId}"},
                        params: {"ParentId" : "{!contentFolderId}"},
                        headers: headersData,
                        init: function () {
                            this.on("maxfilesexceeded", function (data) {
                                var res = eval('(' + data.xhr.responseText + ')');

                            });
                            this.on("removedfile", function (file) {
                                console.log(file.uploadId);
                                this.deleteFile(file,this.options.url);
                                //refreshAttachments();
                            });
                            this.on("success", function (file,resp) {
                                file.uploadId = resp.id;
                                //refreshAttachments();

                            });

                        }
                    });
               console.log({!success});            
            </script>


 
James LoghryJames Loghry
The link looks okay, although it's the incorrect case.  Try changing "Feeditem" to "FeedItem" to see if that does anything?  Also, a great tool for this is the REST explorer in workbench (https://workbench.developerforce.com).

If fixing the case doesn't work, try debugging the javascript (using the browser's developer console and debugger; statements for example) to see if there's anything out of the ordinary there.

Good luck!
mike1051mike1051
I tried chnging the case.It didn't work.
I tried debugging the javascript

Anything else you can suggest.??? Its urgent :(
Its been 3 hours
Failed to load resource: the server responded with a status of 400 (Bad Request)
https://c.cs84.visual.force.com/services/data/v36.0/sobjects/FeedItem/

 
James LoghryJames Loghry
Are you specifying the correct Authorization Bearer header as defined in this example? https://developer.salesforce.com/blogs/developer-relations/2013/06/calling-the-force-com-rest-api-from-visualforce-pages-revisited.html

If that doesn't help, and I could be wrong here, but I think Feed Items and other Chatter related objects now only come back via the "Connect API".  Meaning you can still fetch them using the REST API, it's just a different end point.  For Feed Items, this would resemble the following:
 
/services/data/v36.0/chatter/feed-elements?q=james


Unfortunately, the feed-elements URI needs a query parameter, so you'll need to specify that in your string.  And it may or may not return all the information you're looking for, otherwise you're potentially looking at additional connect api calls.
mike1051mike1051
headersData["Authorization"] = "Bearer {!$Api.Session_ID}";
                sfdcurl = '/services/data/v36.0/chatter/feed-elements?q=james';
                Dropzone.autoDiscover = false;

I am still facint he exact same issue.
Authorization Bearer should eb correct as below is working and i am able to upload file to atachment object..

Any more suggestions.?
 
sfdcurl = '/services/data/v27.0/sobjects/Attachment/';