• David98
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I'm just getting started with trying to use the Salesforce API, and I will admit I don't quite understand how it all fits together yet. With my first attempt at a simple script:

Code:
#!/usr/bin/perl -w
use strict;
use WWW::Salesforce::Simple;

# Authenticate with the Salesforce API based on command line parameters.
my $sforce = WWW::Salesforce::Simple->new(
        'username' => 'x',
        'password' => 'x',
);

my %lead = (
        "type"  => "Lead",
        "Email" => 'test@test.com',
        "LeadSource" => "Web Registration",
        "Company" => "Test Co",
        "Country" => "US",
        "FirstName" => "Test",
        "LastName" => "Person",
        "web_reg_dest__c" => "http://www.test.com/",
);

my $result = $sforce->create(%lead);
if ($result->result->{"success"} eq "false") {
        print $result->result->{errors}->{message} . "\n";
}

I'm receiving the error: "Unable to find a de-serializer for the type {http://www.w3.org/2001/XMLSchema}anyURI"

I have found that if I remove the "http://" from the value of web_reg_dest__c then the lead is successfully created.




Message Edited by Kingsley on 02-08-2007 04:59 PM

Hello,
We've been using the Perl API since October for a 'web to lead' type application. Since the new year, we've been experiencing a lot of problems with the API not sending the data to Salesforce.
The code has an error check in it where we check for "success" in the XML, but that code never executes. When we look at our logs, we see that there is no "success" variable to check. Almost like we aren't receiving a response at all.

Has anyone else experienced these intermittent problems? If so, have you fixed them and how?

I've posted our code here in case there is something messed up with it. Thanks in advance!

Code:
#START Salesforce
use WWW::Salesforce::Simple;
 # Authenticate with the Salesforce API based on command line parameters.
 my $sforce = WWW::Salesforce::Simple->new(
  'username' => 'xxxxxxxx@xxxxxxxxx.xxx',
  'password' => 'xxxxxx'
 );

 #create lead
 my %lead;
 $lead{'type'} = 'Lead';

 my ($first, $last) = split(/ /, $FORM{'contact'}, 2);
 unless ($last) {
  $last = $first; $first = "";
 }
 $lead{'FirstName'} = $first if $first;
 $lead{'LastName'}  = $last if $last;

 $lead{'Company'} = $FORM{'company'};
        $lead{'Street'} = $FORM{'address1'} . " " . $FORM{'address2'};
        $lead{'City'} = $FORM{'city'};
        $lead{'State'} = $FORM{'state'};
        $lead{'PostalCode'} = $FORM{'zip'};
 $lead{'Phone'} = $FORM{'phone'};
 $lead{'Website'} = $FORM{'url'};
 $lead{'Email'} = $FORM{'email'};
        if (length($FORM{'other'}) > 0) {
         $lead{'LeadSource'} = $FORM{'source'} . " -- " . $FORM{'other'};
        } else {
         $lead{'LeadSource'} = $FORM{'source'};
 }
        $lead{'Sales_Region__c'} = $FORM{'salesregion'};
        $lead{'Found_us_from__c'} = $fus;
        $lead{'Sales_Description__c'} = $FORM{'descript'};
        $lead{'URL_Title__c'} = $FORM{'title'};
        $lead{'Initial_Keywords__c'} = $FORM{'keywords'};
        $lead{'Google_Results__c'} = "PageRank:$rf[3]\n    Inbound Links: $rf[4]\n    Site Pages Spidered: $rf[5]\n\n";


 #submit lead to salesforce
 my $res = $sforce->create(%lead);
 if ($res->result->{"success"} == "false") {
  print $res->result->{errors}->{message} . '\n';
 }
# END Salesforce