in reply to Re^3: Consuming A Web Service
in thread Consuming A Web Service
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Consuming A Web Service
by pryrt (Abbot) on Nov 03, 2016 at 15:47 UTC | |
|
Re^5: Consuming A Web Service
by NetWallah (Canon) on Nov 03, 2016 at 17:25 UTC | |
by pryrt (Abbot) on Nov 03, 2016 at 18:02 UTC | |
by NetWallah (Canon) on Nov 03, 2016 at 20:12 UTC | |
by pkupnorth (Novice) on Nov 04, 2016 at 15:18 UTC |