+ Start a Discussion

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/';


              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,
                        dictCancelUpload:"Cancel Upload",
                        dictCancelUploadConfirmation:"Are You Sure?",
                        //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) {
                            this.on("success", function (file,resp) {
                                file.uploadId = resp.id;



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!
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)

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:

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.
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/';