I'm using the following code which works for several other templates:
Code:
def uploadTemplate(url, token, xml):
template_data = '{"jsonrpc" : "2.0", "method": "configuration.import", "params": {"format" : "xml", "rules" : { "templates": { "createMissing": "true", "updateExisting": "true"}, "applications": { "createMissing": "true", "updateExisting": "true" }, "items": { "createMissing": "true", "updateExisting": "true" }, "triggers": { "createMissing": "true", "updateExisting": "true" }, "graphs": { "createMissing": "true", "updateExisting": "true" }, "discoveryRules": { "createMissing": "true", "updateExisting": "true" }, "screens": { "createMissing": "true", "updateExisting": "true" }, "groups": { "createMissing": "true" }, "hosts": { "createMissing": "true", "updateExisting": "true" }, "images": { "createMissing": "true", "updateExisting": "true" }, "maps": { "createMissing": "true", "updateExisting": "true" }, "templateLinkage": { "createMissing": "true" }, "templateScreens": { "createMissing": "true", "updateExisting": "true" }}, "source": "' + xml + '"}, "auth": "' + token + '", "id": 1}'
json_header = {'content-type': 'application/json-rpc'}
try:
xml_payload = requests.post(url,
data=template_data,
headers=json_header)
print xml_payload.headers
return xml_payload.json()
except:
print "Unexpected error: %s" % sys.exc_info()[0]
raise
Comment