+ Start a Discussion
Francis Gerard AlcalaFrancis Gerard Alcala 

Leads web service call


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.setOperation(OperationEnum.insert);
        job = connection.createJob(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.