Accessing the REST API using curl

When you use curl, you log in at the beginning of your session and log out at the end of the session. When you log in, you must save the cookie returned from the login request so that you can pass that same cookie value to the switch in subsequent curl commands.

Prerequisites
  • Access to the switch REST API must be enabled.

Procedure
  1. To access the ArubaOS-CX REST API using curl, use curl version 7.35 or later. The examples provided in this document are tested with version 7.35.
  2. For all curl commands, use the -k option to disable certificate validation.

    The switch uses self-signed certificates. By default, the curl program attempts to verify certificates against its list of certificate authorities, and attempts to verify self-signed certificates fail. Therefore you must use the –k option to disable attempts to verify self-signed certificates against a certificate authority.

  3. Start your session by logging in. When you log in, save the cookie file by specifying the -c option with a file name.
  4. In all subsequent curl commands—including logging out—pass the cookie value back to the switch by specifying the -b option with the same file name.
  5. At the end of the session, log out of the switch using curl.
    IMPORTANT:

    Logging out at the end of the session is important because the number of concurrent HTTPS sessions per client and per switch are limited, and session cookies are not shared across devices and scripts.