clickatell / clickatell-python

Python library to interact with the Clickatell SMS gateway.
https://www.clickatell.com
MIT License
7 stars 5 forks source link

Key error using your API #3

Open ognjen011 opened 4 years ago

ognjen011 commented 4 years ago

Ok so i am using your API in a very simple script to send sms out pretty much identical as your example. It worked for a couple of months without a problem. The other day i started to get an error like below. the message still gets delivered but i would like to resolve the below problem. I just modified this line to pass a data as a variable:

response = clickatell.sendMessage(['1111111111'], "My Message rest")

response = clickatell.sendMessage([to], content)

Error:

File "/usr/lib/zabbix/alertscripts/clickatellsms.py", line 14, in response = clickatell.sendMessage([to], content) File "/usr/local/lib/python2.7/dist-packages/clickatell/rest/init.py", line 40, in sendMessage content = self.parseResponse(self.request('messages', data, {}, 'POST')); File "/usr/local/lib/python2.7/dist-packages/clickatell/init.py", line 45, in parseResponse response['error'] = response['body']['error'] KeyError: 'error'

hobbes commented 1 year ago

exact same behaviour here with python 3.10. Please update that library !!

Support-Symplenormics commented 1 month ago

@hobbes and @ognjen011 I got the same thing and I had to remove line 45 of the clickatell/init.py file. I think is a typo done by the developer they were meant to get the error from the response['message'] (as response['message']['error']) and not from the response['body']. The reason for this is that the message key contains the error key and not the body it resides in the mesomehow it