HP Insight Control Server Provisioning 7.3 Update 1 Administrator Guide

13 Advanced topics
REST calls for logging in and logging out
All REST (Representational State Transfer) calls require that you first log in and get a token, perform
your intended REST call, and then log out. The log in and log out REST calls are shown here. You
will be directed to this topic for logging in and logging out information from all the other REST call
topics in this chapter.
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 in the following table:
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 username 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 can invoke cURL with the following associated responses:
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
Content-Type: application/json
Via: 1.1 cic.dns.hp
cache-control: no-cache
Transfer-Encoding: chunked
{"sessionID":"<user-authorization-token>"}
REST calls for logging in and logging out 99