HPE Primera Storage
1824009 Members
4011 Online
109667 Solutions
New Discussion

REST API response error

 
SOLVED
Go to solution
raysa123
Established Member

REST API response error

 

Hi,

Is anyone can see what is the problem when I trying to execute the curl command to get the CPG's on the Primera storage?  Got the key from successful POST method using my user and password as Header then when i try to use the key to get the CPG's info I got invalid session key. 

% showwsapi
-Service- -State- HTTPS_Port -Version- ----------API_URL----------
Enabled Active 443 1.10.0 https://PRIMERA_IPADDRESS/api/v1

See curl command and error below:

curl -k -i -X GET -H "X-HP3PAR-WSAPI-SessionKey: 0-eb6507cde8a2fb82cc579ce1a5d55398-2a1ce167" \
> https://PRIMERA_IPADDRESS/api/v1/cpgs
HTTP/2 403
cache-control: no-cache, no-store, private, max-age=-1, must-revalidate
content-language: en-US
content-security-policy: default-src 'self' https://www.google-analytics.com/ ; script-src 'unsafe-eval' 'self' https://www.googletagmanager.com/gtag/js https://www.google-analytics.com/analytics.js 'sha256-v0Q8X6xSNmwWcfldSEWqW+3imFpJurfHYdywm3hw6+w=' ; style-src 'nonce-d29tZSBjb29sIHN0cmluZyB3aWxsIHBvcCB1cCAxMjM=' 'self' blob:; frame-src 'self'; object-src 'self'; media-src 'self' data: blob:; font-src 'self' data:; frame-ancestors 'self'
content-type: application/json
pragma: no-cache
server: hp3par-wsapi
strict-transport-security: max-age=31536000; includeSubDomains;
vary: Accept-Encoding
vary: Origin
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
content-length: 39

{"code":6,"desc":"invalid session key"}

9 REPLIES 9
support_s
System Recommended

Query: REST API response error

System recommended content:

1. HPE XP Common Services REST API Reference Guide (10.9.3)

 

Please click on "Thumbs Up/Kudo" icon to give a "Kudo".

 

Thank you for being a HPE valuable community member.


Accept or Kudo

raysa123
Established Member

Re: Query: REST API response error

thanks but still could not get what is wrong in my syntax above as I am using the latest key generated using put method. the documentation is for HPE XP still confusing to me.

Is there any idea on what will be the correct syntax base on my error above?

 

veeyarvi
HPE Pro
Solution

Re: REST API response error

Hi Raysa123,

I assume, the correct session key is used.
curl -k -H 'Content-Type:application/json' --data '{ "user":"username" ,"password":"user_password"}' -X POST https://<array ip>/api/v1/credentials {"key":"0-5a2d2c9b9ec72c42c5dd0cf1b544c226-19dec165"}

Fetch the session key from above output and use it with the key name " X-HP3PAR-WSAPI-SessionKey "

Try the below command:

curl -ki https://PRIMERA_IPADDRESS/api/v1/cpgs X GET -H "X-HP3PAR-WSAPI-SessionKey":"<session key from above output>"

Regards,
Veeyaarvi



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
raysa321
Occasional Advisor

Re: REST API response error

Hi @veeyarvi ,

You provide the right syntax! thanks a lot for sharing.

By the way is it possible to fetch or query a specific key to display the value from the response body? For example i want to monitor only the Primera system "freeCapacityMiB" from the output of this endpoint "/api/v1/system'. Hope you could extend your kindness for a little more if you know something about it.

 

below is my example result  using this endpoint  "/api/v1/system'.

curl -k https://<not revealing IPAddr>/api/v1/system?query="name" -X GET -H "X-HP3PAR-WSAPI-SessionKey":"0-f288cbcf927e53fa0ccd9a4afd41ae6b-7feee367"
{"code":9,"desc":"unsupported operation for the resource"}

none right now.
veeyarvi
HPE Pro

Re: REST API response error

Hi Raysa321,

I do not think 'freeCapacityMiB' is a supported one. As per Success | HPE Alletra 9000: Web Services API v1.10 developer reference , I could see 'freeMiB' and 'freeInitializedMiB' might be the one you are looking for (as per requirement).

Regards,
Veeyaarvi



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
raysa321
Occasional Advisor

Re: REST API response error

Hi @vveeyarvi,

would you help what is the correct query? i tried it the one i showed above but it returns an error.
none right now.
veeyarvi
HPE Pro

Re: REST API response error

Hi Raysa,

The below will list the complete endpoint

key=$(curl -k -H 'Content-Type:application/json' --data '{ "user":"username" ,"password":"password"}' -X POST IP address/api/v1/credentials | jq -r '.key'); curl -k -H "Accept:application/json" -H "Content-Type:application/json" -H "X-HP3PAR-WSAPI-SessionKey":"$key" IP Address/api/v1/system | jq -r

I think jq has options to fileter the required output (only) but I am yet to explore that option. 

Regards,
Veeyaarvi



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
raysa321
Occasional Advisor

Re: REST API response error

hi @veeryarvi

this is a great help. appreciate the assistance and thank you.
none right now.
support_s
System Recommended

Query: REST API response error

Hello,

 

Let us know if you were able to resolve the issue.

If you are satisfied with the answers then kindly click the "Accept As Solution" button for the most helpful response so that it is beneficial to all community members.

 

 

Please click on "Thumbs Up/Kudo" icon to give a "Kudo".


Accept or Kudo