function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Francis Gerard AlcalaFrancis Gerard Alcala 

Leads web service call

Hi,

How can I create a job that retrieves all the Leads records?
I currently have these codes, are these correct?
 
public static void main(String[] args)
      throws AsyncApiException, ConnectionException, IOException {
        BulkExample example = new BulkExample();
        // Replace arguments below with your credentials and test file name
        // The first parameter indicates that we are loading Account records
//        example.runSample("Account", "myUser@myOrg.com", "myPassword", "mySampleData.csv");
        example.runSample("Lead", "email@myemail.com", "password", "mySampleData.csv");
    }

private JobInfo createJob(String sobjectType, BulkConnection connection)
          throws AsyncApiException {
        JobInfo job = new JobInfo();
        job.setObject(sobjectType);
//        job.setOperation(OperationEnum.insert);
        job.setOperation(OperationEnum.query);
        job.setContentType(ContentType.CSV);
        job = connection.createJob(job);
        System.out.println(job);
        return job;
    }

Also, what should be the content of my csv file?
 
Daniel BallingerDaniel Ballinger
Where are you getting the BulkExample code from?

I can see you are creating the Query job (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_jobs_create.htm)above. Is there more code to add the actual query?

Generally speaking, you need to follow the steps in Use Bulk Query (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_using_bulk_query.htm). You will POST the SOQL query to https://instance_name—api.salesforce.com/services/async/APIversion/job/jobid/batch after first creating the Job.