green-api/whatsapp-api-client-python

Getting JSONDecodeError on invalid response from API

Closed this issue · 5 comments

Traceback (most recent call last):
File "/workspaces/whatsapp-api-client-python/main.py", line 15, in
main()
File "/workspaces/whatsapp-api-client-python/main.py", line 9, in main
response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
File "/workspaces/whatsapp-api-client-python/whatsapp_api_client_python/tools/sending.py", line 32, in sendMessage
return self.api.request(
File "/workspaces/whatsapp-api-client-python/whatsapp_api_client_python/API.py", line 93, in request
self.__handle_response(response)
File "/workspaces/whatsapp-api-client-python/whatsapp_api_client_python/API.py", line 117, in __handle_response
json.loads(response.text), ensure_ascii=False, indent=4
File "/home/codespace/.python/current/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/home/codespace/.python/current/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/codespace/.python/current/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Good afternoon!
For prompt answers regarding working with the service, we recommend contacting technical support:


In a line of code:
response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
You must correctly specify the phone number as the first argument, not the instance number. You can find out more here:

@MominIqbal-1234 Thanks for submitting the issue. The bug has been fixed in version 0.0.45. You can install the new version with command pip install whatsapp-api-client-python -U.

2024-03-12 22:15:04:whatsapp-api-client-python:ERROR:Request was failed with status code: 401. Data:
None

Which method returns a 401 error? Please describe the problem in more detail in the technical support channel:

Status 401 indicates that you have a problem with your instance or token. You probably did not change the initial instance and token. You can get your data in your Green API account, API url and Media url fields for sending media files.
Read more about the error in the article on our website: https://green-api.com/en/docs/api/common-errors/
We also clarify that this is a response from the API and not a library error