Back to OP5 Monitor FAQ

API queries for objects containing a slash

If you attempt an API query requesting information about an object that contains a slash, you may get an error. Here’s a curl example requesting the attributes of the “test_service_/boot” service on host “la-master01”:

# curl -G --data-urlencode -s --insecure -u monitor:monitor "https://localhost/api/config/service/la-master01;test_service_/boot"

This fails:

{
  "error": "Invalid request",
  "full_error": "Please visit https://localhost/api/help with a browser to see documentation"
}

The solution to this is to not only url-encode the slash once ("%2F"), but url-encode the url-encoded string ("%252F"). Meaning, instead of passing this URL:

https://localhost/api/config/service/la-master01;test_service_/boot

Pass this:

https://localhost/api/config/service/la-master01;test_service_%252Fboot

Response:

{
  "host_name": "la-master01",
  "service_description": "test_service_/boot",
  "check_command": "check_dummy",
  "check_command_args": "1",
  "template": "default-service",
  "register": true,
  "file_id": "etc/services.cfg",
  (...)
["Geneos"] ["FAQ"]

Was this topic helpful?