This curl line works perfectly:
curl -v -H "Content-Type: application/json" -k -d "{\"UserName\":\"test\",\"Password\":\"test\"}" -X POST "https://xxx.xxx.xxx.xxx/redfish/v1/SessionService/Sessions"
but when trying to translate into Perl, I've a http 500 error code in response.
Here an excerpt of my code:
$CLIENT=REST::Client->new(
{
host => $HOSTURL,
timeout => 300,
}
);
# Formatage de la requete
$URL = "/redfish/v1/SessionService/Sessions";
$ACTION = "POST";
%CONTENT_JSON = (
'UserName' => 'test',
'Password' => 'test'
);
%SESS_HEADERS = (
'Content-Type' => 'application/json',
);
$CONTENT_JSON = encode_json(\%CONTENT_JSON);
# Lancement de la requete
print Dumper $ACTION,$URL,$CONTENT_JSON,\%SESS_HEADERS;
$CLIENT->request($ACTION,$URL,$CONTENT_JSON,\%SESS_HEADERS);
$REPCODE = $CLIENT->responseCode();
print Dumper $REPCODE;
print Dumper $CLIENT->responseContent();
exit;
and the results:
$VAR1 = 'POST';
$VAR2 = '/redfish/v1/SessionService/Sessions';
$VAR3 = '{"UserName":"test","Password":"test"}';
$VAR4 = {
'Content-Type' => 'application/json'
};
$VAR1 = 500;
$VAR1 = 'Can\'t connect to xxx.xxx.xxx.xxx:443
So, where am I wrong?
This looks like a clue:
$VAR1 = 'Can\'t connect to xxx.xxx.xxx.xxx:443
Are you sure that you've got the correct domain name? And does the resource work over HTTPS?
Oh and I bet REST::Client uses LWP::UserAgent, so you'll need LWP::Protocol::https installed as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.