CURL Data Format and API Key Examples

Cloudera Data Visualization provides examples of API Key in CURL data format.

When you add the APIKey to the request header and avoid explicit login, all interactions become simpler. The examples in this article use an APIKey obtained through the Manage API Keys interface, on the host:port/arc/apps/apikeys browser page of the DataViz installation The actual APIKey and the method of retrieving the key depends on the user system.

See Example 1 to learn how to get all roles information, and Example 2 to change the description of a role.

Example 1: Getting all roles

To use CURL to obtain a full dump of all roles, use the following command.

Note that the output is piped to the standard python JSON dumper for easier reading; it is not necessary for CURL access.

curl -s \
 -X GET \
 -H "Authorization: apikey ApiKey" \
 api_url/roles?detail=1> | python -m json.tool

Note that the login URL has the form [http|https]:/host:port/arc/apps/login. For syntax of other parameters, see Admin API syntax parameters.

Example 2: Changing the role description

To change the description for role ID 3, use the following command.

For CURL to supply data through the POST method, use the application/x-www-form-urlencoded content type.

curl -s \
 -X POST \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: apikey ApiKey" \
 -d 'data=[{"desc":"Updated description again"}]' \
 api_url/roles/3

For the definition of fields for each data type, see Data type details. For syntax of other parameters, see Admin API syntax parameters.