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);
app.listen(app.get('port'));
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' }