[ic] HTTP POSTing to another server from IC

Grant listbox at email.com
Thu Aug 21 15:00:57 EDT 2003


*snip*

> How about running your sub through perl to check the syntax
> (perl -cw perl_script, for example) before trying to get Interchange
> to cope with it? :)
>
> Good luck,
>
> John

Sorry about that.  I've cleaned that up and I still get the same error when
restarting IC.  Running it through perl -cw I get the following:

Number found where operator expected at posttourl.tag line 2, near
"Interpolate 1"
        (Do you need to predeclare Interpolate?)
syntax error at posttourl.tag line 2, near "Interpolate 1"
Semicolon seems to be missing at posttourl.tag line 2.
syntax error at posttourl.tag line 33, near "}"
posttourl.tag had compilation errors.

But I copied lines 2 and 33 straight from the example posttourl tag.  Here's
my tag the way it is now:

Usertag posttourl Order url params apicall
Usertag posttourl Interpolate 1
Usertag posttourl Routine <<EOR
sub {
require HTTP::Request;
require HTTP::Headers;
require LWP::UserAgent; # SSL cabable if Crypt::SSLeay installed
        my $url=shift; my $params=shift;
        $ENV{'HTTPS_VERSION'} = '3';
        $ENV{'HTTPS_CERT_FILE'}='xxx.pem';
        $ENV{'HTTPS_KEY_FILE'}='xxx.key';

        my $page="";
        my $request=new HTTP::Request 'POST' => $url;
        $request->Content-Type('text/xml');
        $request->Content($params);
        $request->Content-Length(length($params));
        $request->X-API-COMPATIBILITY-LEVEL(305);
        $request->X-API-SESSION-CERTIFICATE('staticinfo');
        $request->X-API-DEV-NAME(staticinfo);
        $request->X-API-APP-NAME(staticinfo);
        $request->X-API-CERT-NAME('staticinfo');
        $request->X-API-CALL-NAME($apicall);
        $request->X-API-SITEID(0);
        $request->X-API-DETAIL-LEVEL(0);

        my $ua=LWP::UserAgent->new;
        my $response = $ua->request($request);
        $page.=$response->as_string,"\n\n\n";
        $page.=$response->code,"\n";
        $page.=$response->message,"\n";
        return $page;
}
EOR

Just to reiterate, I'm trying to post an XML request and a series of
specific headers to a remote server via HTTP.

- Grant



More information about the interchange-users mailing list