Home > Cloud Cruiser 4 > REST API reference > Example code > Perl

Perl

Table of contents
No headers

The following example Perl script snippet fetches the resource information for the resource with headerId 10021.

#!/usr/local/bin/perl ‐w
use LWP::UserAgent;
$myurl = "http://localhost:8080/rest/v1/resources/resource/10021";
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'GET' => "$myurl";
$req‐>header('Accept' => 'application/xml');
#set the Basic Authentication header
$req‐>authorization_basic('username', 'password');
#send request
$res = $ua‐>request($req);
#check the response
if ($res‐>is_success) {
  print $res‐>content;
} else {
  print "Error: " . $res‐>status_line . "\n";
  #The server error message is in the response body
  print $res‐>content
}
Last modified

Tags

This page has no custom tags.

Classifications

This page has no classifications.
© Copyright 2018 Hewlett Packard Enterprise Development LP