You need to sign in to do that
Don't have an account?
sachin kadian 5
Chrome Extension with forcetk unauthorized (401) error
HI,
I created one chrome extension and i am trying to upload one attachment to a record using forcetk. Here is my content script -
Now the thing is, if i am running this extension from any standard page or home page of salesforce, it is running fine and creating the Attachement but if i am on a visualforce page and trying to run this extension, i am getting 401(unauthorized) error. I am adding both the screenshots. Any help would be great here.
Screeshot from standard page -
From VF Page -
Thanks,
I created one chrome extension and i am trying to upload one attachment to a record using forcetk. Here is my content script -
function getValueFromCookie(b) { var a, c, d, e = document.cookie.split(";"); for (a = 0; a < e.length; a++) if (c = e[a].substr(0, e[a].indexOf("=")), d = e[a].substr(e[a].indexOf("=") + 1), c = c.replace(/^\s+|\s+$/g, ""), c == b) return unescape(d) } var showingApi = false; var keyPrefixToObjName = new Object(); chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { var sendResponse = sendResponse; var client = new forcetk.Client(); client.setSessionToken(getValueFromCookie("sid")); console.log(getValueFromCookie("sid")); if(request.queryString == 'getCurrentPageFields'){ console.log('==inside=='); var file = request.fileToUpload; console.log(file); //$('input[id$="_Id"]').each(function(){ // var pId = $(this).val(); // console.log(pId); client.createBlob('Attachment', {'parentId': '0012800000VNnuV','Name': 'testImg','ContentType': 'image/jpeg'},'test from tk', 'Body',file,function(response){ console.log(response); console.log(response.id); }, function(request, status, response){ $("#message").html("Error: " + status); }); //}) } // Needed so the callbacks can return a response when they complete return true; });
Now the thing is, if i am running this extension from any standard page or home page of salesforce, it is running fine and creating the Attachement but if i am on a visualforce page and trying to run this extension, i am getting 401(unauthorized) error. I am adding both the screenshots. Any help would be great here.
Screeshot from standard page -
From VF Page -
Thanks,