• micah
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

I'm trying to use the Bulk API to execute a query and get ~230,000 records back. But when I execute the query, instead I get a cryptic id number and no records at all. Can anyone help?

I'm using both the Force.com Toolkit for PHP and the PHP Bulk API found here: http://wiki.developerforce.com/index.php/Web_Services_API#PHP

In short, here's what I'm doing:

// connect to Salesforce using Force.com Toolkit for PHP
$sf = new SforceEnterpriseClient();
$sf->createConnection("enterprise.wsdl.xml");
$login = $sf->login($username, $password.$security_token);

// initialize the PHP Bulk API
$sfbulk = new BulkApiClient($login->serverUrl, $login->sessionId);
$sfbulk->setCompressionEnabled(true);

// create a Bulk API job
$job = new JobInfo();
$job->setObject('Contact');
$job->setOpertion('query');
$job->setContentType('CSV');
$job->setConcurrencyMode('Parallel');
$job = $sfbulk->createJob($job);

// add the batch and close the job
$batch = $sfbulk->createBatch($job, "SELECT Id, FirstName FROM Contact LIMIT 10");
$sfbulk->updateJobState($job->getId(), "Closed");

// monitor the batch status until it's done
while($batch->getState() == "Queued" || $batch->getState() == "InProgress") {
    sleep(5);
    $batch = $sfbulk->getBatchInfo($job->getId(), $batch->getId());
}
if($batch->getState() == "Failed") {
    echo("Batch failed!");
    exit();
}

// get the results
$results = $sfbulk->getBatchResults($job->getId(), $batch->getId());
echo("Batch complete! Results: ".json_encode($results));

And the results I'm getting from running this script are:

Batch complete! Results: <result-list xmlns="http://www.force.com/2009/06/asyncapi/dataload"><result>752A0000000GnBh</result></result-list>

I have tried several different queries. Some of the batches that have more complicated joins had a "Failed" status, but this is a really simple query, and I should be getting 10 contacts back. Instead I'm getting "752A0000000GnBh" with no indication of what this is an id for.

When I do the same thing except all with the Force.com Toolkit for PHP it works fine and I get the 10 results I'm looking for. The problem is when I want to select all of the records in the Contact table I run into the API request limit very quickly and can only process about 20,000 records in a single day. It seems like using the Bulk API would fix this (I don't have to constantly make queryMore() requests), but it doesn't appear to be working.

I googled around for a solution and found this blog post: http://blogs.developerforce.com/engineering/2011/03/bulk-api-queries.html

It says the query command in the Bulk API is a pilot feature and "Since this feature is still in pilot, first you will need to contact your Salesforce representative to have it enabled for your organization." I have called custoimer service and they assured me that my Salesforce account does have this enabled. Which would make sense, because it never gave me an error message.

Am I just using the Bulk API wrong? If so, how can I use it to get records from a query? If not, is the Bulk API broken?

  • August 02, 2011
  • Like
  • 0

I am trying to write a program that uses the Force.com Toolkit for PHP. When I run queries that select fields that are part of the Convio Common Ground package those fields are not getting returned in the results.

 

When I run those same exact queries with the same username, password, and security token using Force.com Explorer I do get those fields in the result.

 

I have verified that the user I'm using has the Common Ground package marked as Active. While logged on as this user I generated a new enterprise.wsdl.xml which contains these custom Common Ground fields in it, and I'm loading this file when connecting to SalesForce. But still I'm not able to select any Common Ground fields.

 

Any idea how I can make this work? Thanks!

  • July 26, 2011
  • Like
  • 0

I'm trying to use the Bulk API to execute a query and get ~230,000 records back. But when I execute the query, instead I get a cryptic id number and no records at all. Can anyone help?

I'm using both the Force.com Toolkit for PHP and the PHP Bulk API found here: http://wiki.developerforce.com/index.php/Web_Services_API#PHP

In short, here's what I'm doing:

// connect to Salesforce using Force.com Toolkit for PHP
$sf = new SforceEnterpriseClient();
$sf->createConnection("enterprise.wsdl.xml");
$login = $sf->login($username, $password.$security_token);

// initialize the PHP Bulk API
$sfbulk = new BulkApiClient($login->serverUrl, $login->sessionId);
$sfbulk->setCompressionEnabled(true);

// create a Bulk API job
$job = new JobInfo();
$job->setObject('Contact');
$job->setOpertion('query');
$job->setContentType('CSV');
$job->setConcurrencyMode('Parallel');
$job = $sfbulk->createJob($job);

// add the batch and close the job
$batch = $sfbulk->createBatch($job, "SELECT Id, FirstName FROM Contact LIMIT 10");
$sfbulk->updateJobState($job->getId(), "Closed");

// monitor the batch status until it's done
while($batch->getState() == "Queued" || $batch->getState() == "InProgress") {
    sleep(5);
    $batch = $sfbulk->getBatchInfo($job->getId(), $batch->getId());
}
if($batch->getState() == "Failed") {
    echo("Batch failed!");
    exit();
}

// get the results
$results = $sfbulk->getBatchResults($job->getId(), $batch->getId());
echo("Batch complete! Results: ".json_encode($results));

And the results I'm getting from running this script are:

Batch complete! Results: <result-list xmlns="http://www.force.com/2009/06/asyncapi/dataload"><result>752A0000000GnBh</result></result-list>

I have tried several different queries. Some of the batches that have more complicated joins had a "Failed" status, but this is a really simple query, and I should be getting 10 contacts back. Instead I'm getting "752A0000000GnBh" with no indication of what this is an id for.

When I do the same thing except all with the Force.com Toolkit for PHP it works fine and I get the 10 results I'm looking for. The problem is when I want to select all of the records in the Contact table I run into the API request limit very quickly and can only process about 20,000 records in a single day. It seems like using the Bulk API would fix this (I don't have to constantly make queryMore() requests), but it doesn't appear to be working.

I googled around for a solution and found this blog post: http://blogs.developerforce.com/engineering/2011/03/bulk-api-queries.html

It says the query command in the Bulk API is a pilot feature and "Since this feature is still in pilot, first you will need to contact your Salesforce representative to have it enabled for your organization." I have called custoimer service and they assured me that my Salesforce account does have this enabled. Which would make sense, because it never gave me an error message.

Am I just using the Bulk API wrong? If so, how can I use it to get records from a query? If not, is the Bulk API broken?

  • August 02, 2011
  • Like
  • 0

I am trying to write a program that uses the Force.com Toolkit for PHP. When I run queries that select fields that are part of the Convio Common Ground package those fields are not getting returned in the results.

 

When I run those same exact queries with the same username, password, and security token using Force.com Explorer I do get those fields in the result.

 

I have verified that the user I'm using has the Common Ground package marked as Active. While logged on as this user I generated a new enterprise.wsdl.xml which contains these custom Common Ground fields in it, and I'm loading this file when connecting to SalesForce. But still I'm not able to select any Common Ground fields.

 

Any idea how I can make this work? Thanks!

  • July 26, 2011
  • Like
  • 0