search

Using cURL

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


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

If doing this in bash, escape your quotes inside your JSON object or wrap the entire object in quotes different from the quotes inside the JSON object (e.g. single-quotes outside, double-quotes inside or vice versa).

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


URL endpoint

Specify the URL of the router

https://example.zenoss.com/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\": \"example.zenoss.com\", \"deviceClass\": \"/Server/Linux\"}, \"tid\": 1}]" https://example.zenoss.com/zport/dmd/device_router
Adding a device to 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\": \"example.zenoss.com\", \"deviceClass\": \"/Server/Linux\"}, \"tid\": 1}]" https://example.zenoss.io/cz0/zport/dmd/device_router