I have a problem in send Restful request to HotelsPro web service.
Iam trying to send request to this link https://api-test.hotelspro.com:443 with basic credentials but I get error every time "Authentication credentials were not provided" although this credentials is working on browser.My code like follow
sub getJSONdata {
my ($SupplierXMLServer, $message, $compressed,$timeOut) = ();
($SupplierXMLServer, $message, $compressed,$timeOut) = @_;
$SupplierXMLServer='https://api-test.hotelspro.com/api/v2/search/?destination_code=20b05&checkin=2016-11-09&checkout=2016-11-12¤cy=USD&client_nationality=PS&pax=2';
my $username = "Epilgrim";
my $password = "xxxxxxxxxx";
use LWP::UserAgent;
my $userAgent = LWP::UserAgent->new(agent =>"1");
$userAgent->credentials('https://api-test.hotelspro.com:443', 'api', $username , $password);
$userAgent->timeout($timeOut) if($timeOut); # in seconds
use HTTP::Request::Common;
my $response = '';
if($compressed){
$response = $userAgent->request( GET $SupplierXMLServer,
Content_Type => 'application/json',
Accept_Encoding => "gzip,deflate",
Content => $message);
}
else{
$response = $userAgent->request( GET $SupplierXMLServer,
Content_Type => 'application/json',
Content => $message);
}
return $response->error_as_HTML unless $response->is_success;
#return $response->content;
if($compressed){
return $response->decoded_content;
}
else{
return $response->content;
}
}
Please help me to write the correct code and send the request in correct way to get valid response.