The documentation provided is somewhat confusing, and the solution I developed was obtained from the nifi api deploy groovy script at https://github.com/aperepel/nifi-api-deploy
Ultimately, to directly create a POST template, you can use the following in Python requests
requests.post("%s/nifi-api/controller/templates"%(url,), files={"template":open(filename, 'rb')})
Where file name is the name of your template and url is the path to your nifi instance. I did not understand this directly in curl, but it will hopefully get people with a similar question to start!
Edit: Please note that you also cannot load a template with the same name as an existing template. Before reloading, be sure to delete the existing template. Using the unravel library to parse the XML template, the following script works just fine:
import untangle, sys, requests def deploy_template(filename, url): p = untangle.parse(filename) new_template_name=p.template.name.cdata r=requests.get("%s/nifi-api/controller/templates"%(url,), headers={"Accept":"application/json"}) for each in r.json()["templates"]: if each["name"]==new_template_name: requests.delete(each["uri"]) requests.post("%s/nifi-api/controller/templates"%(url,), files={"template":open(filename, 'rb')}) if __name__=="__main__": deploy_template(sys.argv[1], sys.argv[2])
source share