+ Start a Discussion

Salesforce.pm error

Every now and then I see this error:
500 read failed: at Salesforce.pm line 80

recorded in my error capture file. That specific line reads:

my $r = $client->query($self->get_session_header(),
SOAP:ata->name('query' => $in{'query'}),
SOAP::Header->name('QueryOptions' => \SOAP::Header->name('batchSize' => $in{'limit'})));

(I think I've slightly modified it from the original Salesforce.pm.)

Any ideas why this might be happening? It's intermittent, so it's clearly not a syntax error or something like that.
Ron HessRon Hess
read can fail for any number of network related issues, on your end or on sf.com end.
does it (frequency ) change if you increase your time-out ?
i get these and just catch them, re-login and go again...

they sometimes occur when the API server has a hicup.
What? The API server hiccups?!

Actually, that's the direction I'm leaning towards. The frequency is too low for any meaningful experiment on the timeout. I'll try to add some error trapping code.
Stumped a little bit on the error trapping. I'd like to trap this:
my $result = $port->query('query' => $query_str,'limit' => 1000);

So, I'd like to do something like:
eval "my $result = ...";

except that $result is not recognized outside the eval. So I have to initialize $result just before doing the eval, except now I don't know what class to set it to when I do that.

Any sample code on the error trapping I can use for reference?

Ron HessRon Hess
errors are returned in the result object
you can have / see both faults and errors...

# query returns a SOAP SOM

my $result = $port->query('query' => $query_str,'limit' => 1000);

print Dumper($result) ; # lots of info here...

if ($result->fault() ) {
croak "\ncode >",$result->faultcode(), "",$result->faultstring(), "}
if ($result->valueof("//result/errors")) {
carp Dumper $result->valueof("//result/errors"); }

# and then to pull out the array of records i use
my @records = $result->valueof('//queryResponse/result/records');