Cannot set SNMPv3 parameters on host via REST API

Hi

I am trying to create a host using the REST API (testing via Postman but will use python for production) and setting SNMPv3 attributes at the same time. I’ve manually configured a host with example config and then used the API to read the JSON representation of the attributes and then replicated the json list in a create host API request - eg below

POST https://checkmk/localsite/check_mk/api/v0/domain-types/host_config/collections/all
header: Accept: application/json
Body:
{
“folder”: “/”,
“host_name”: “example8.com”,
“attributes”: {
“ipaddress”: “192.168.0.18”,
“snmp_community”: [
“authPriv”,
“SHA-256”,
“SNMPV3USER”,
“authpass123”,
“DES”,
“privpass123”
],
“tag_snmp_ds”: “snmp-v2”
}
}

The result is as follows (it seems that the snmp_community field is string only and doesn’t accept a list of SNMPv3 parameters as is displayed when you do a fetch of a preconfigured host).

{
"title": "Bad Request",
"status": 400,
"detail": "These fields have problems: attributes",
"fields": {
    "attributes": {
        "snmp_community": [
            "Not a valid string."
        ]
    }
}

}

Is it possible to configure SNMPv3 via the new REST API?
If so, what is the correct format for the parameters please?

Thanks

Paul

The REST API currently has a data type issue where lists cannot be processed. The developers already work to fix that. You need to wait for a next patch release.

2 Likes

Ok thanks for the update. Much appreciated.

is this fixed now i want to use this specific use case?

for me it works if I put the snmp settings in a dictionary not a list.

Sample SNMPv3

'snmp_community': {
    'auth_password': 'removed',
    'auth_protocol': 'SHA-1-96',
    'privacy_password': 'removed',
    'privacy_protocol': 'AES-128',
    'security_name': 'snmpv3username',
    'type': 'v3_auth_privacy'
}

Sample SNMPv2

'snmp_community': {
    'community': 'public',
    'type': 'v1_v2_community'
},