cURL as the REST API Client
To test communication to the array using cURL as the Linux-based REST API client:
-
Use any web browser to export the array CA certificate to the API client
machine.
Nimble OS $ cert --list Name Subject =================== array: <redacted> array-ca: <redacted> group: <redacted> <----- We will call this: array_cert_filename custom: no certificate custom-csr: <redacted> Use Name =================== HTTPS: group APIs: group <----- Nimble OS $ cert --info group Certificate: Data: Version: 3 (0x2) . . . -------- <---copy from here . . . -------- <--- to here >>Create file on the client side with the certificate information. We will call this file cert3 -
Obtain array API version.
$ curl -i -k –cacert <array_cert_filename> -X 'GET' https://127.0.1.1:5392/versionsExpected output (formatted):
{ "data": [ { "name": "v1" } ] } -
Authenticate with the array for a session token.
curl -i -k --cacert <cert_file> -X 'POST' -d '{"data":{"password":"<password>","username":"admin"}}' https://<array_ip>:5392/v1/tokensExpected output (formatted):
{ "data": { "app_name": "", "creation_time": 1430505404, "id": "19088d2734f073eee40000000000000000000002bf", "last_modified": 1430505404, "session_token": "7f39888e5b9ba094f4f3103fb3f923b2", "source_ip": "10.12.18.202", "username": "admin" } } -
Test the API by using "GET" to retrieve the array name.
curl -i -k --cacert <cert_name> -X 'GET' -H "X-Auth-Token:<token_string>" https://<array_name>:5392/<version_number>/arraysExpected output (formatted):
{ "data": [ { "id": "09088d2734f073eee4000000000000000000000001", "name": "sjc-array355" } ], "endRow": 1, "startRow": 0, "totalRows": 1 }