REST APIcURL
cURL
Sample code using cURL
Token-Based HTTPS Request
This is the most basic example of accessing a REST API endpoint using an API token.
It assumes the API token has already been generated, replacing <token>
in the
examples below. It also uses the -k
option for cURL to bypass unknown certificate authority
errors, so it should be used with caution.
$ curl -k -H "Authorization: Bearer <token>" https://cuica-host/v1/system/info
{"version":"1.2.3","buildVersion":"b1bd459", "lastCommitTime":"2025-02-11T01:07:43-05:00","serialNumber":"CUIPRF-XXX"}
Token-Based HTTPS Request with CA
This sample code is similar to the previous, however this specifies a local
root CA (my-cert.pem
) to avoid TLS certificate errors.
$ curl --cacert my-cert.pem \
-H "Authorization: Bearer <token>" https://cuica-host/v1/system/info
{"version":"1.2.3","buildVersion":"b1bd459", "lastCommitTime":"2025-02-11T01:07:43-05:00","serialNumber":"CUIPRF-XXX"}
Session-Based HTTPS Request with CA
This sample code shows how to make an HTTPS request using a
using a custom PEM file (my-certs.pem
) for the TLS certificate chain
and by using an HTTP session instead of a token.
$ curl --cacert my-certs.pem -X POST -c cookie_jar.txt -d"username=<username>&password=<password>" https://cuica-host/login
Found. Redirecting to /
$ curl --cacert my-certs.pem -b cookie_jar.txt https://cuica-host/v1/system/info
{"version":"1.2.3","buildVersion":"b1bd459","lastCommitTime":"2025-02-11T01:07:43-05:00","serialNumber":"CUIPRF-XXX"}
Next