I am using JSforce, a module of Node.js for Salesforce. The login credentials are obviously not correct in this script but they are correct in original script and they are working fine. Here is app.js

var http = require('http');
var express = require("express");
var app = express();
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
oauth2 : {
// you can change loginUrl to connect to sandbox or prerelease env.
loginUrl : 'loginURl',
clientId : 'client_id',
clientSecret : 'secret_id_35686',
redirectUri : 'localhost:4000/'
var username = 'username';
var password = 'passowrd';
app.set('view engine', 'pug');
//body to be sent for post
var body = {
Auth0__Id: 'test_id',
us__c : 'Pending - New Hire',
Recope : '012F0000001E1lvIAC',
conn.login(username, password, function(err, userInfo) {
if (err) { return console.error(err); }
app.get('/forms', function(req, res){
res.render('form.pug', { check : conn.accessToken });
// this is where the problem is in my opinion
var options = {
'Content-Type': 'application/json'
conn.apex.post(conn.instanceUrl +"/services/data/v36.0/sobjects/SFDC_Employee__c/", body, options, function(err, res) {
if (err) { return console.error(err); }
console.log("response: ", res);
app.set('port', process.env.PORT || 4000);

Here is the link to JSforce Post Apex Instructions https://jsforce.github.io/jsforce/doc/Apex.html#post. Here is the example of JSforce with Apex Rest API. https://jsforce.github.io/document/#apex-rest

Is it necessary for me to include "options" parameter for defining metadata and headers? If yes! How can I do it? I think I am not defining it the right way?. When I run this script I get this error.

{ [NOT_FOUND: The requested resource does not exist] name: 'NOT_FOUND', errorCode: 'NOT_FOUND' }

1 Answer 1


SFDC has two ways of exposing REST API

1)Custom apex Built

2)Standard REST API

You are trying to use JSForce for apex built while your endpoint is of Standard REST API .

Use the below for standard REST API to create records

// Single record creation
Auth0_Id__c: 'sfnewcheckst_d',
Status__c: 'Pending - New Hire',
RecordTypeId: '012F00000lvIAC'
}, function(err, ret) {
  if (err || !ret.success) { return console.error(err, ret); }
     console.log("Created record id : " + ret.id);
   // ...
  • Okay. Thanks. Can you specify it little bit more? I have tried doing this: conn.instanceUrl +"/services/data/v36.0/sobjects/" + body + "/". May 15, 2016 at 13:48
  • Your object name is SFDC__c .I see only one underscore May 15, 2016 at 13:49
  • Oh. Okay. But in original script its two. I think that's the not problem. Should SFDC__c should be variable and contain the body of the post request in your opinion? May 15, 2016 at 13:50
  • Is your field names also end with __c May 15, 2016 at 13:51
  • Also remove options and try. Does that work in REST API utility in workbench? May 15, 2016 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .