I want to access the REST-API from Perl (SOAP works) and found: http://miguel.gualdron.com/2011/06/using-salesforcecoms-rest-api-from-perl.html

I tried this code:


use lib qw( /cw/CWPerlModules );
use feature say;

use CW::SalesForce::API;
use WWW::Mechanize;
use Data::Dumper;

my $sf = CW::SalesForce::API->instance();
my $sid = $sf{_}->{sf_sid};

my $mech = WWW::Mechanize->new();
$mech->add_header("Authorization" => "OAuth $sid");
$mech->add_header("X-PrettyPrint" => '1');
print $mech->content;

xy1.salesforce.com is address of our sandbox and also used for login with SalesForce::API.

Problem is that the login (with Mechanize) doesn't work:

Error GETing https://xy1.salesforce.com/services/data/v37.0/sobjects/: Unauthorized at ./sf_test.pl line 17.

Error occurs when I try to get an url.

SF documentation says that I have to use OAuth 2.0 authentication for the REST-API.

Can someone point me in the right direction for using OAuth and the REST-API in Perl?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.