0

Completely new to the Salesforce API. I'd like to simply download all lead and contact information from a connected user's account - that is, anything which has an "Email" field. I've only briefly used Salesforce before so I may be in way over my head.

I'm currently using the jsForce API wrapper for NodeJS, but everything in the docs seems far too advanced for my needs.

I'm trying to do a request like this:

conn.query("SELECT Id, Name, Email FROM Leads", function(err, result) {
        if (err) { return console.error(err); }
        console.log("total : " + result.totalSize);
        console.log("fetched : " + result.records.length);
        console.log(util.inspect(result, false, null));

      });

However, this gets me the result:

Object type 'Leads' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.] name: 'INVALID_TYPE', errorCode: 'INVALID_TYPE' }

Knew it wouldn't be that easy. However, looking in my Salesforce account (my organisation is called "Warm") I can see that I do have plenty of leads and they all have email addresses under the column "Email":

enter image description here

Clearly I'm doing something very wrong. I'd like to download all leads, opportunities, contacts, orders etc but I barely know where to start / the Salesforce API docs have been no help at all (I've been reading for a couple of hours but it's all very theoretical and mostly Java based!)

Any idea what I can do to simply bulk download Salesforce data through an oAuth2 authenticated API call?

3

Your query fails because your object name (Leads) is wrong. You must use object names in singular.

Instead of:

SELECT Id, Name, Email FROM Leads

Try:

SELECT Id, Name, Email FROM Lead

As far as i know all salesforce API's can be used with oauth2 tokens, just use the access token as session id.

If you expect a lot of data you should consider to use the bulk API (JSForce contains an implementation).

As an overview which API you should use for certain use cases, take a look at Which API Should I Use?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.