search

Using cURL

API calls to Zenoss Resource Manager and Zenoss Cloud Collection Zones can be made using the Linux curl command.

Authentication

For Resource Manager, specify the username and password in quotes with a colon between them using the -u switch

-u "api-username:api-password"


For Zenoss Cloud, specify your api key in the headers of the request

-H "z-api-key: <your_api_key>"


Request type and other headers

Set the request method to POST with -X

-X POST


Set content-type to “application/json” in the headers

-H "Content-Type: application/json"


JSON body

Send your JSON data with -d

  • The entire JSON body must be quoted when invoking curl from the shell.
  • JSON syntax requires that all strings are in double quotes.
  • The easiest way to meet both requirements is to surround the JSON data in single quotes as shown below.


-d '{"action": "DeviceRouter", "method": "addDevice", "data": [{"deviceName": "device.example.com", "deviceClass": "/Server/Linux"}], "tid": 1}'


URL endpoint

Specify the URL of the router

Resource Manager example endpoint
https://zenapi.zenoss.example.com/zport/dmd/device_router
Zenoss Cloud example endpoint
https://example.zenoss.io/cz0/zport/dmd/device_router


Example Requests

Adding a device to Zenoss Resource Manager with cURL
curl -u "api-username:api-password"  -X POST -H "Content-Type: application/json" -d '{"action": "DeviceRouter", "method": "addDevice", "data": [{"deviceName": "device.example.com", "deviceClass": "/Server/Linux"}], "tid": 1}' https://zenoss.example.com/zport/dmd/device_router


Adding a device to a Collection Zone with cURL
curl -H "z-api-key: <your_api_key>" -X POST -H "Content-Type: application/json" -d '{"action": "DeviceRouter", "method": "addDevice", "data": [{"deviceName": "device.example.com", "deviceClass": "/Server/Linux"}], "tid": 1}' https://example.zenoss.io/cz0/zport/dmd/device_router