- Community Home
- >
- Storage
- >
- Midrange and Enterprise Storage
- >
- HPE 3PAR StoreServ Storage
- >
- Perl REST client
-
-
Forums
- Products
- Servers and Operating Systems
- Storage
- Software
- Services
- HPE GreenLake
- Company
- Events
- Webinars
- Partner Solutions and Certifications
- Local Language
- China - 简体中文
- Japan - 日本語
- Korea - 한국어
- Taiwan - 繁體中文
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Blog, Poland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-01-2017 08:03 PM
05-01-2017 08:03 PM
Perl REST client
Does anyone test perl REST client ? I can run curl successfully, but fails through REST client. Tried user id and passwd, also encrypyted authorization Here is my sample code.
#!/usr/local/bin/perl -l
use JSON;
use REST::Client;
use MIME::Base64;
### Skip SSL certificate verification
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
# Set the request parameters
my $host = 'http://<3par storage>:8008';
my $user = '3parid';
my $pwd = 'passwd';
my $client = REST::Client->new(host => $host);
my $encoded_auth = encode_base64("$user:$pwd", '');
# Get Volumes
$client->GET('/api/v1/volumes',
{'Authorization' => "Basic $encoded_auth",
# {'Authorization' => "Basic n3bHCMfkbtPvs0DmBtfnEa==",
'Accept' => 'application/json'});
print 'Response: ' . $client->responseContent() . "\n";
print 'Response status: ' . $client->responseCode() . "\n";
foreach ( $client->responseHeaders() ) {
print 'Header: ' . $_ . '=' . $client->responseHeader($_) . "\n";
}
Always get "invalid session key". same code works perfectly on Netapp's and EMC
Error message
Response: {"code":6,"desc":"invalid session key"}
Response status: 403
Header: Connection=close
Header: Date=Mon, 01 May 2017 15:55:27 GMT
Header: Server=hp3par-wsapi
Header: Content-Type=application/json
Header: Client-Date=Mon, 01 May 2017 15:55:27 GMT
Header: Client-Peer=<3par ip>:8008
Header: Client-Response-Num=1
Following curl syntax works fine.
curl -k -H "Accept:application/json" -H "Content-Type:application/json" --data-binary '{"user":"3parid","password":"passwd"}' 'https://<3par ip>:8080/api/v1/credentials'
{"key":"0-7c2e5ee3yecccd8x430ec1zd56d5308c-d25c0759"}
curl -k -H "X-HP3PAR-WSAPI759: 0-7c2e5ee3yecccd8x430ec1zd56d5308c-d25c0759" 'https://<3par IP>:8080/api/v1/cpgs'
Was wondering I have to pass the session key instead of username/passwd through REST client. But do not know how.
Appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-05-2017 08:51 PM
05-05-2017 08:51 PM
Re: Perl REST client
I assume WSAPI is enabled?
showwsapi
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2022 Hewlett Packard Enterprise Development LP