HP Insight Control Server Provisioning 7.2 Administrator Guide

5 Advanced topics
5.1 REST APIs to enable HP Support access or add a server via iLO
REST (Representational State Transfer) calls to enable/disable HP Support services access or to
add a server via iLO require three REST calls. The first call sets up a user session and generates
an authentication token and the second REST call enables/disables services access or adds a
server via iLO. Finally, the user session needs to be ended with a REST call for logging out.
In this discussion we use the open-source cURL utility to make the REST calls. The cURL open-source
project is located at: http://curl.haxx.se/. You can invoke cURL from a command line on either
Linux or Windows.
Each REST call is an HTTP request and associated response. The request includes the URL, message
type, HTTP headers, request body, and response body.
5.1.1 REST call to create the user session and get the authentication token
The REST call to create the user session requires you to pass an appliance administrator user’s
credentials (<administrator-user>/<administrator-password> as identified below),
and the REST call will respond with a user authorization token (<user-authorization-token>
as identified below).
A list of the components of the REST call is shown below:
DescriptionREST component
https://<appliance-hostname-or-address>/rest/login-sessions?action=login
where you supply <appliance-hostname-or-address>
URL:
POSTMessage Type:
accept: application/jsonHTTP Headers:
content-type: application/json
accept-language: en-us (optional)
{“userName”:”<administrator-user>,”password”:”<administrator-password>”}
where you supply appliance administrator userNname and password
Request Body:
{"sessionID":"<user-authorization-token>"}
where you retrieve the user authorization token for use in the second REST call
Response Body:
You invoke cURL as follows and will see the associated response shown below:
cURL command on Linux:
curl -i -k -H "accept: application/json" -H "content-type: application/json"
-H "accept-language: en-us" -X POST
https://<appliance-hostname-or-address>/rest/login-sessions?action=login
-d '{"userName":"<administrator-user>","password":"<administrator-password>"}'
cURL command on Windows:
curl -i -k -H "accept: application/json" -H "content-type: application/json"
-H "accept-language: en-us" -X POST
https://<appliance-hostname-or-address>/rest/login-sessions?action=login
-d {\"userName\":\"<administrator-user>\",\"password\":\"<administrator-password>\"}
Response on success:
HTTP/1.1 200 OK
Date: Fri, 08 Feb 2013 20:44:01 GMT
34 Advanced topics