I want get some informix from pve with python3.(i am new)
the worked and I can get the ticket
but when I try to get nodes
I got error:
i can print ticket in the second, the only difference is params = {}.
Code:
url = self.urlBase + 'access/ticket'
params = {'username': userName, 'password': passWord}
data = bytes(urllib.parse.urlencode(params), encoding='utf8')
response = urllib.request.urlopen(url, data=data)
fields = json.loads(response.read().decode('utf-8'))
self.TICKET = fields['data']['ticket']
but when I try to get nodes
Code:
url = self.urlBase + 'nodes'
params = {'PVEAuthCookie': self.TICKET}
data = bytes(urllib.parse.urlencode(params), encoding='utf8')
response = urllib.request.urlopen(url, data=data)
fields = json.loads(response.read().decode('utf-8'))
I got error:
Code:
response = urllib.request.urlopen(url, data=data)
File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.5/urllib/request.py", line 472, in open
response = meth(req, response)
File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.5/urllib/request.py", line 510, in error
return self._call_chain(*args)
File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: No ticket
i can print ticket in the second, the only difference is params = {}.