NetWallah, here is the code with your suggestion as listed:
use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw(GET); my $ua = LWP::UserAgent->new; my $endpoint = 'Http://www.somecompany.com:8081/api/ourCompany/getASN +'; my $req = HTTP::Request->new('GET', 'Accept' => 'application/xml'); $req->url($endpoint); my $resp = $ua->request($req); my $message = $resp->content; print "printing message: $message\n\n";
I get the error message "bad header argument at code.pl line 8." Which is the HTTP::Request->new line.
Here is the working code with the slight modifications:
use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw(GET); use XML::Simple; my $ua = LWP::UserAgent->new; my $endpoint = 'Http://www.somecompany.com:8081/api/ourCompany/getASN +'; my $req = HTTP::Request->new(GET => $endpoint); $req->header(Accept => 'application/xml'); $req->url($endpoint); my $resp = $ua->request($req); my $message = $resp->content; print "printing message: $message\n\n";
Thanks,
pkupnorth
In reply to Re^4: Consuming A Web Service
by pkupnorth
in thread Consuming A Web Service
by pkupnorth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |