HP 3PAR StoreServ 7450 4-node HP 3PAR Web Service API 1.2 Developer's - Page 25

The ref Member, HTTP Error Codes, Request Input and Optional Members, Date: Tue, Wed

Page 25 highlights

The ref Member In the event of an error that may occur for several reasons, the ref member may specify the reason for the error. For example, if the client were to send an incorrect value for a JSON member, then the server may be able to identify which member had the incorrect value. NOTE: There are errors in which a ref member is neither necessary nor useful, so it may not appear for all errors. Sample Request POST /api/v1/hosts HTTP/1.1 Content-Type: application/json Host: storsys1:8080 Accept: application/json {"name":abc} Sample Response HTTP/1.1 400 Bad Request Date: Tue, Wed, 21 May 2013 22:15:52 GMT Server: hp3par-wsapi Content-Type: application/json Connection: close {"code":60,"desc":"JSON syntax error","ref":"name"} 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 17). The following is an example of a bad client request, followed by the server response showing how the API error code 5 is associated 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 bob's 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"} Request Input and Optional Members For some API operations, such as POST, the client passes a JSON object as the message body. The JSON object includes required parameters, or members, for the operation and may include optional members as well. Most operations have optional members. Request Input and Optional Members 25

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107

The
ref
Member
In the event of an error that may occur for several reasons, the ref member may specify the reason
for the error. For example, if the client were to send an incorrect value for a JSON member, then
the server may be able to identify which member had the incorrect value.
NOTE:
There are errors in which a
ref
member is neither necessary nor useful, so it may not
appear for all errors.
Sample Request
POST /api/v1/hosts
HTTP/1.1
Content-Type: application/json
Host: storsys1:8080
Accept: application/json
{"name":abc}
Sample Response
HTTP/1.1 400 Bad Request
Date: Tue, Wed, 21 May 2013 22:15:52 GMT
Server: hp3par-wsapi
Content-Type: application/json
Connection: close
{"code":60,"desc":"JSON syntax error","ref":"name"}
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 17)
.
The following is an example of a bad client request, followed by the server response showing how
the API error code 5 is associated 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 bob
s 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"}
Request Input and Optional Members
For some API operations, such as POST, the client passes a JSON object as the message body.
The JSON object includes required parameters, or members, for the operation and may include
optional members as well. Most operations have optional members.
Request Input and Optional Members
25