Calling the REST API with curl
You can call the Cloudera SQL Stream Builder (SSB) REST API from the command line with curl. Each request names the SSB host, the API path, and the session cookie.
A request has the following form:
curl -s -b "hadoop-jwt=${HADOOP_JWT}" \
-H "Content-Type: application/json" \
-X <method> "https://<instance-name>-ssb-sse.<domain>/api/v2/<path>" \
-d '<json-body>'
| Option | Purpose |
|---|---|
-b "hadoop-jwt=…" |
Sends the session cookie. For how to get the cookie, see Programmatic API access. |
-H "Content-Type: application/json" |
Required for requests that have a body |
-X <method> |
The HTTP method: GET, POST, PUT, PATCH, or DELETE. GET is the default. |
-d '<json-body>' or -d @<file>.json |
The request body, inline or from a file |
--cacert <ca-certificate-file> |
Optional: The certificate authority that signed the certificate of your Anywhere Cloud installation, if your system does not trust it. |
The following example lists the jobs of a project:
curl -s -b "hadoop-jwt=${HADOOP_JWT}" \
"https://<instance-name>-ssb-sse.<domain>/api/v2/projects/<project-id>/jobs"
Responses are JSON objects or arrays, with the same HTTP status codes that the API Explorer lists. To format a response, pipe it to a JSON tool such as jq.
For worked examples, see Using Cloudera SQL Stream Builder REST API.
