Skip to main content
Post Reopened by Vigneshwaran G, Mohith Shrivastava, Adrian Larson, dphil, Ratan Paul
added more explanation
Source Link

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use themy active SessionID from my session to query Opportunities using Javascript. I've tried passing the sessionID via Ajax but that is not working (getting 401 error).

Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "sid"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

UPDATE: The answer to my question is on the right track. ForceTK does access the API via Javascript - which is what I'm loooking to do. However, it's failing to resolve names on a chrome extension.

How can I make a REST call with with the sessionID to return a list of opportunities?

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use the SessionID from my session to query Opportunities. Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "sid"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

How can I make a REST call with with the sessionID to return a list of opportunities?

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use my active SessionID from my session to query Opportunities using Javascript. I've tried passing the sessionID via Ajax but that is not working (getting 401 error).

Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "sid"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

UPDATE: The answer to my question is on the right track. ForceTK does access the API via Javascript - which is what I'm loooking to do. However, it's failing to resolve names on a chrome extension.

How can I make a REST call with with the sessionID to return a list of opportunities?

Post Closed as "Needs details or clarity" by Adrian Larson, Eric, Vigneshwaran G, Boris Bachovski, Ratan Paul
corrected session id cookie name
Source Link

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use the SessionID from my session to query Opportunities. Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "JSESSIONID""sid"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

How can I make a REST call with with the sessionID to return a list of opportunities?

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use the SessionID from my session to query Opportunities. Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "JSESSIONID"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

How can I make a REST call with with the sessionID to return a list of opportunities?

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use the SessionID from my session to query Opportunities. Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "sid"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

How can I make a REST call with with the sessionID to return a list of opportunities?

Source Link

Salesforce REST Call with SessionID

I've got a Chrome extension running while I'm signed in to Salesforce. I want to use the SessionID from my session to query Opportunities. Here's my code so far:

function processSessionID(sessionID) {
    console.log(sessionID);
    // Make the REST call here
}


chrome.cookies.getAll({
  "domain": "lightning.force.com", "name": "JSESSIONID"
}, function(cookies) {
  for(i = 0; i < cookies.length; i++) {
    console.log(cookies[i].value);
    var sessionID = cookies[i].value;
    processSessionID(sessionID)
  }
});

How can I make a REST call with with the sessionID to return a list of opportunities?