HP 3PAR Web Service API 1.3.1 Developer's Guide

HTTP Error Codes
In addition to the API-specific error information, the response to a client request that has failed will
include an HTTP error code. Each API error code is associated with an HTTP status code as shown
in “Generic WSAPI code Member Status and Error Codes” (page 22).
The following is an example of a bad client request, followed by the server response showing API
error code 5 in association with HTTP status code, 403 Forbidden:
Request
POST /api/v1/credentials HTTP/1.1
Content-Type: application/json
Host: storsys1:8080
Content-Length: 44
Expect: 100-continue
Accept: application/json
{"password":"not bobs password","user":"bob"}
Response
HTTP/1.1 403 Forbidden
Date: Tue, Wed, 31 Oct 2012 22:15:52 GMT
Server: hp3par-wsapi
Content-Type: application/json
Connection: close
{"code":5,"desc":"invalid user or password"}
System Access
This section discusses the use of session keys with the WSAPI. Session keys enable access to the
HTTP methods for a single session.
Creating Credentials
In order to use the Web Services, you must create a session key by providing a username and
password. The username and password are the same that you would use to access the HP 3PAR
storage server through the HP 3PAR Command Line Interface (CLI) or the HP 3PAR Management
Console (MC). The authorization carries the same user permissions for the WSAPI as for the CLI
or MC, in that you have permission to perform the same operations through the API (where available)
as you would with the CLI or MC.
1. Create a session key using the HTTP POST method with a URI of the following format:
https://<storage_system>:8080/api/v1/credentials
2. The message body of the request is a JSON object, with members as shown in Table 7 (page
38).
Table 7 Session Key Message Body Member JSON Objects
DescriptionValueJSON TypeMember
User’s name.Usernamestringuser
User’s password.User's passwordstringpassword
NOTE: For error output for this and other conditions, see “HTTP Status and Error Codes (page 21).
38 Accessing the WSAPI