ich möchte eine Verbindung zu einem Rest api mit dem folgenden Code zur Ruhe:Python verbinden api
data = requests.get("http://pbx/rest/login").json()
head = {'loginType' : 'Internal','nonce' : data["nonce"], 'secret' : (hashlib.sha1((LOGIN_ID+data['nonce']+PASSWORD).encode('utf-8')).hexdigest())}
data_new = requests.post('http://pbx/rest/login',data=head)
print(data_new)
anfordernden die Nonce von der TK-Anlage ganz gut funktioniert, dann muss ich das Login-Geheimnis generieren und haben posten es an die TK-Anlage und die Antwort sollte ein Zeichen sein
aber print (data_new) jus zeigt mir und print (data_new.json()) stürzt mit dem folgenden Fehler:
Traceback (most recent call last):
File "starface.py", line 14, in <module>
Connect()
File "starface.py", line 12, in Connect
data_new = requests.post(SERVER+"login",data=head).json()
File "C:\Users\BüroNotebook\AppData\Local\Programs\Python\Python35-32\lib\site
-packages\requests\models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\BüroNotebook\AppData\Local\Programs\Python\Python35-32\lib\json
\__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "C:\Users\BüroNotebook\AppData\Local\Programs\Python\Python35-32\lib\json
\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\BüroNotebook\AppData\Local\Programs\Python\Python35-32\lib\json
\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)