Jenkins Python API, create_node(), error: 400
Question: I'm setting my jenkins environment and, as part of this process, I need to
create a slave node.

Bellow follow the script that is crashing:

> ` import jenkins server = jenkins.Jenkins('http://localhost:9090')
> server.create_node('slave') `

Follows the output:

` Traceback (most recent call last): File "<stdin>", line 1, in <module> File
"/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 1156, in
create_node self._build_url(CREATE_NODE, params), b'')) File
"/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 341, in
jenkins_open response = urlopen(req, timeout=self.timeout).read() File
"/usr/lib/python2.7/urllib2.py", line 127, in urlopen return _opener.open(url,
data, timeout) File "/usr/lib/python2.7/urllib2.py", line 410, in open
response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 523,
in http_response 'http', request, response, code, msg, hdrs) File
"/usr/lib/python2.7/urllib2.py", line 448, in error return
self._call_chain(*args) File "/usr/lib/python2.7/urllib2.py", line 382, in
_call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line
531, in http_error_default raise HTTPError(req.get_full_url(), code, msg,
hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request `


Answer: Use jenkinsapi module,

    
    
    from jenkinsapi.jenkins import Jenkins
    server = Jenkins('http://localhost:9090')
    server.create_node('slave')
    

