How to use the SalesForce API?

2.4k Views Asked by At

I'm trying to use an express/node application to make an api call to the salesforce api and return me data according to the records I have with the account.

But it is returning this:

[{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}] 

Currently my code looks like this

  const express  = require('express')
  const app = express();
  var request = require('request');
  app.get('/',(req,res, next) =>{
    request({
      url: 'https://nav4.lightning.force.com/services/data"',
    }).pipe(res);
  });
})

const port = process.env.PORT || 3000; app.listen(3000, ()=> 
console.log(`listening on port ${port}`))

I think my URL is wrong and might need authentication also.

2

There are 2 best solutions below

0
On

For consume the Salesforce API below are the Details to notes.

  1. Find which api to consume REST OR SOAP
  2. Needs :
    1. Base URL
    2. Endpoint URL
    3. Consumer Key and secret key

This are the Point To archive

Below are for Your Reference

https://developer.salesforce.com/page/Consuming_Force.com_SOAP_and_REST_Web_Services_from_.NET_Applications

https://trailhead.salesforce.com/content/learn/modules/apex_integration_services

0
On

You do need to authenticate first to https://login.salesforce.com. I would suggest reading and following the documentation at their documentation. The username password flow is only recommended for testing purposes though, so once you get it working you might want to look into a different oauth flow if you are building a real application depending on your use case.