Centreon API错误:requests.exceptions.ConnectionError :('连接已中止。',gaierror(-2,'名称或服务未知'))

时间:2017-10-10 20:39:53

标签: python

我只是尝试对Centreon API进行身份验证,以便获取API令牌。我在Centreon服务器上运行这个python脚本,但它失败了。有没有人曾经使用过这个API?我需要在代码中改变什么?

import requests

requests.get('http://api.mydomain.tld/api/index.php?action=authenticate', auth=('my_username', 'my_password'))

编辑: 这是我收到的输出:

Traceback (most recent call last):
  File "api.py", line 4, in <module>
    requests.get('http://api.domain.com.tld/api/index.php?action=authenticate', auth=('user', 'password'))
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 68, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

0 个答案:

没有答案