Legacy API Conversion in Perl

Is anyone still using perl cgi scripts to access the API?
If so did you just convert to SAK?

@Tim_Turner I’m not using PERL, and not sure what the syntax should be, but all you should need to do is add the custom header to your request and pass the SAK

X-Keap-Api-Key: SAK_KEY_GOES_HERE

@Tim_Turner, you are going to be one of the very few people using Perl.

I am not a Perl programmer, but I was able to make a REST API request based on the changes that are required for the API.

Below an example Perl script. Your Service Account Key needs to be put for the “$key” variable.

#!/usr/bin/env perl
 
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request ();
use JSON::MaybeXS qw(encode_json);
use Data::Dumper;

my $url = 'https://api.infusionsoft.com/crm/rest/v2/contacts';
my $key = '<< SERVICE ACCOUNT KEY >>';

my $header = ['Content-Type' => 'text/xml', 'Accept-Charset' => 'UTF-8,ISO-8859-1,US-ASCII', 'Expect' => '', 'X-Keap-API-Key' => $key  ];
my $data = [];
my $encoded_data = encode_json($data);
 
my $ua  = LWP::UserAgent->new;

$ua->ssl_opts(
    SSL_verify_mode => 0, 
    verify_hostname => 0
);

my $req = HTTP::Request->new('GET', $url, $header);

my $res = $ua->request($req);

print $res->content;

If you are using the XML-RPC method, then you need to change the API URL Endpoint to the below.

"https://api.infusionsoft.com/crm/xmlrpc"

The Header will need to be changed so that it includes the “X-Keap-API-Key” parameter with a reference to the Service Account Key.

Then the rest of your code will carry on running as normal.

Hope that helps.