API configure service with special character in description
Posted: Fri Jun 28, 2019 7:36 am
Hello there,
I am trying to modify a service configuration using the REST API using a PUT request to apply my modification.
The relevant command is as follows:
PUT "http://#####/nagiosxi/api/v1/config/service/<config_name>/<service_description>apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
All works well when modifying services with regular descriptions, but I am unable to use it on services containing special characters, namely '/'.
I.E.
(From Core Config Manager / Service Manager)
Config Name *
somehost
Description *
GigabitEthernet0/1Bandwidth
(From GET service)
[
{
"config_name": "somehost",
"host_name": [
"somehost"
],
"service_description": "GigabitEthernet0\/1Bandwidth",
"use": [
"xiwizard_switch_port_bandwidth_service"
],
"check_command": "check_xi_service_mrtgtraf!some.rrd!700,300!850,450!M!!!!",
"max_check_attempts": "5",
"check_interval": "5",
"retry_interval": "1",
"check_period": "xi_timeperiod_24x7",
"notification_interval": "60",
"notification_period": "xi_timeperiod_24x7",
"contacts": [
"nagiosadmin"
],
"register": "1"
}
]
The following urls are not able to reach the correct service.
They return a <Response [200]>
{
"error": "Could not update the service specified. Does the service exist?"
}
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0%2F1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0\/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0%5C%2F1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0\\/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0\\\/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
I am using python3 and the requests module to perform the request.
Removing the special character '/' makes the url work correctly but is highly inconvenient.
Is it possible to find the correct expression that can reach the service of the example?
Thank you for your time.
I am trying to modify a service configuration using the REST API using a PUT request to apply my modification.
The relevant command is as follows:
PUT "http://#####/nagiosxi/api/v1/config/service/<config_name>/<service_description>apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
All works well when modifying services with regular descriptions, but I am unable to use it on services containing special characters, namely '/'.
I.E.
(From Core Config Manager / Service Manager)
Config Name *
somehost
Description *
GigabitEthernet0/1Bandwidth
(From GET service)
[
{
"config_name": "somehost",
"host_name": [
"somehost"
],
"service_description": "GigabitEthernet0\/1Bandwidth",
"use": [
"xiwizard_switch_port_bandwidth_service"
],
"check_command": "check_xi_service_mrtgtraf!some.rrd!700,300!850,450!M!!!!",
"max_check_attempts": "5",
"check_interval": "5",
"retry_interval": "1",
"check_period": "xi_timeperiod_24x7",
"notification_interval": "60",
"notification_period": "xi_timeperiod_24x7",
"contacts": [
"nagiosadmin"
],
"register": "1"
}
]
The following urls are not able to reach the correct service.
They return a <Response [200]>
{
"error": "Could not update the service specified. Does the service exist?"
}
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0%2F1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0\/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0%5C%2F1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0\\/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
"http://#####/nagiosxi/api/v1/config/service/somehost/GigabitEthernet0\\\/1Bandwidth&apikey=***&pretty=1&SOME_CHANGE&applyconfig=1"
I am using python3 and the requests module to perform the request.
Removing the special character '/' makes the url work correctly but is highly inconvenient.
Is it possible to find the correct expression that can reach the service of the example?
Thank you for your time.