I am trying to create a bulk api query job using jsforce and nodejs. Below is the method i am calling after getting the access token. But it is not creating the job. Is the below way correct to create a query job.

function createBulkApiQueryJob( sfClient, res ) {
  const query = {
    "operation": "query",
    "query": "SELECT Id FROM Account LIMIT 10",
    "contentType": "CSV",
    "columnDelimiter": "CARET",
    "lineEnding": "CRLF"
  var job = sfClient.bulk.createJob( "Account", "query" );
  var batch = job.createBatch();
  batch.execute( query );
  console.log( batch.Id );


1 Answer 1


It's documented here how to make a bulk query

To pipe to a file use below

var fs = require('fs');
conn.bulk.query("SELECT Id, Name, NumberOfEmployees FROM Account")

To use in your node.js code

 conn.bulk.query("SELECT Id, Name, NumberOfEmployees FROM Account")
  .on('record', function(rec) { console.log(rec); })
  .on('error', function(err) { console.error(err); });


Note that jsforce does not support bulk query 2.0 operation to return jobId and batchID well

I suggest you use bulk API v2.0 and build your own npm module.

I have something started in my repo here. Check here to explore more

  • Hi Mohith.. Hope u r doing well. Saw all your videos very informative.. Here what i am trying to do is create a bulk query job which will query in batch and return the job id and batch ids. Later i can use the jobId to get the results . I dont want to store it in local. Dec 16, 2020 at 17:37
  • @hellraizer Just looked into the jsforce. Seems like it does not support v2.0 well. I suggest you take a look at the sample repo I have shared. Dec 16, 2020 at 17:53

You must log in to answer this question.

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