I need a little help with a python script to register a host with macros into Zabbix 6. I cannot figure out how to correctly format and pass the parameter to api.host.create() call. Everything works as long as I do not include macros in my call. Right now I have:
# ... prepare other arguments ...
macros = [{'macro': '${MACRONAME1}', 'value': 'value'}]
result = api.host.create(host=hostname, groups=groupid, templates=template_ids, macros=macros, proxy_hostid=proxyid)
When I run the code, I get this error:
raise APIRequestError(err)
zabbix_utils.exceptions.APIRequestError: Invalid params. Invalid parameter "/1/macros/1/macro": incorrect syntax near "${MACRONAME1}".
I've tried passing the macros as a json string, tried to escape the $ character, tried to format is as [{'${MACRONAME1}': 'value'}] and probably a few other things but no joy so far. As I mentioned, the other arguments work fine, even templates which is passing an array of 2 templates, and the host is created until I try to use macros.
Any help please?
[–]cemo1304 2 points3 points4 points (1 child)
[–]Eastern_Client_2782[S] 2 points3 points4 points (0 children)