Tooling API - Can't create objects
When I try to create an object such as 'ApexClass', I get the following error:
TypeError: this._createSingle is not a function At: at Tooling.Connection.insert.Connection.create
This is the code:
conn.login(username, password + securityToken, function(err) { if (!err) { const apexBody = [ "public class TestApex {", " public string sayHello() {", " return 'Hello';", " }", "}"].join('\n'); conn.tooling.sobject('ApexClass').create({ body: apexBody }, function(err, res) { if (err) { return console.error(err); } console.log(res); }); } });
I had the same issue with JSforce v 1.9.1. I downgraded to 1.8.5 and was able to use the Tooling API as expected.
I got a similar error this._ensureVersion is not a function and downgrading solved it as well
Upgrading to 1.9.3 will be a better move, as dated now.
@preveenraj are you staying this is fixed in >1.9.3?
Can confirm that this is still an issue in 2.0.0-beta.19. Unable to use the Tooling API functionality for DML operations, throws the error TypeError: this._ensureVersion is not a function.
This should be fixed in v3, see: https://github.com/jsforce/jsforce/discussions/1529