[Melbourne-pm] LWP not giving the expected response

Mithun Radhakrishnan mithunr2003 at gmail.com
Sat Feb 22 01:22:12 PST 2014


Hi Mongers,

I am not getting the proper response from the below URL when used with LWP
request. However curl gives proper response. Do I need to add any thing
extra in the code.  The same perl code works perfectly with other URLs.

http://cgjobjarservice-axzz2sbpnu.elasticbeanstalk.com/service/getLookupData/category


[perl at localhost ~]$  *curl -i
http://cgjobjarservice-axzz2sbpnu.elasticbeanstalk.com/service/getLookupData/category
<http://cgjobjarservice-axzz2sbpnu.elasticbeanstalk.com/service/getLookupData/category>*
*HTTP/1.1 200 OK*
Content-Type: application/json;charset=UTF-8
Date: Sat, 22 Feb 2014 09:12:43 GMT
Server: Apache-Coyote/1.1
transfer-encoding: chunked
Connection: keep-alive

[{"category_id":0,"category_name":"Development","category_description":"Software
Development"},{"category_id":1,"category_name":"Pursuit","category_description":"Pursuit"},{"category_id":2,"category_name":"Information
Gathering","category_description":"Information
Gathering"},{"category_id":3,"category_name":"Documentation","category_description":"Documentation"}]

[perl at localhost ~]$ *./mytest/Tool-link/get.pl <http://get.pl> *
Request URL    :
http://cgjobjarservice-axzz2sbpnu.elasticbeanstalk.com/service/getLookupData/category
Request Method    :GET
*Response Status    :400*
Response Content    :<html><head><title>Apache Tomcat/7.0.42 - Error
report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP Status 400 - </h1><HR size="1"
noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b>
<u></u></p><p><b>description</b> <u>The request sent by the client was
syntactically incorrect.</u></p><HR size="1" noshade="noshade"><h3>Apache
Tomcat/7.0.42</h3></body></html>

[perl at localhost ~]$ cat ./mytest/Tool-link/get.pl
#!/usr/bin/env perl

use LWP::UserAgent;
use HTTP::Request;
use Data::Dumper;

my $method = 'GET';
my $uri =
'
http://cgjobjarservice-axzz2sbpnu.elasticbeanstalk.com/service/getLookupData/category
';
#$uri = 'http://www.thomas-bayer.com/sqlrest/PRODUCT/49';
my $ua = LWP::UserAgent->new;

my $request = HTTP::Request->new( $method, $uri );
my $response = $ua->request($request);

print "Request URL\t:",    $response->request->url,    "\n";
print "Request Method\t:", $response->request->method, "\n";
print "Response Status\t:",  $response->code,    "\n";
print "Response Content\t:", $response->content, "\n";

#print Dumper($response);
[perl at localhost ~]$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20140222/1a88efbc/attachment.html>


More information about the Melbourne-pm mailing list