Open louwjlabuschagne opened 4 years ago
Not able to send a message with WA yet. Getting the following error in a notebook.
# client credentials are read from TWILIO_ACCOUNT_SID and AUTH_TOKEN
client = Client()
# this is the Twilio sandbox testing number
from_whatsapp_number=KONT_WA
# replace this number with your own WhatsApp Messaging number
to_whatsapp_number=MY_WA
client.messages.create(body='Ahoy, world!',
# application_sid=TWILIO_ACCOUNT_SID,
---------------------------------------------------------------------------
TwilioRestException Traceback (most recent call last)
in
10 # application_sid=TWILIO_ACCOUNT_SID,
11 from_=from_whatsapp_number,
---> 12 to=to_whatsapp_number)
~/Documents/gitProjects/stats/kont_venv/lib/python3.7/site-packages/twilio/rest/api/v2010/account/message/__init__.py in create(self, to, status_callback, application_sid, max_price, provide_feedback, validity_period, force_delivery, smart_encoded, persistent_action, from_, messaging_service_sid, body, media_url)
79 })
80
---> 81 payload = self._version.create(method='POST', uri=self._uri, data=data, )
82
83 return MessageInstance(self._version, payload, account_sid=self._solution['account_sid'], )
~/Documents/gitProjects/stats/kont_venv/lib/python3.7/site-packages/twilio/base/version.py in create(self, method, uri, params, data, headers, auth, timeout, allow_redirects)
207
208 if response.status_code < 200 or response.status_code >= 300:
--> 209 raise self.exception(method, uri, response, 'Unable to create record')
210
211 return json.loads(response.text)
TwilioRestException: HTTP 401 error: Unable to create record: Authenticate
And the following on the CLI:
(kont_venv) devscripts (master): python whatsapp.py
Traceback (most recent call last):
File "whatsapp.py", line 28, in <module>
to=to_whatsapp_number)
File "/Users/louwjlab/Documents/gitProjects/stats/kont_venv/lib/python3.7/site-packages/twilio/rest/api/v2010/account/message/__init__.py", line 81, in create
payload = self._version.create(method='POST', uri=self._uri, data=data, )
File "/Users/louwjlab/Documents/gitProjects/stats/kont_venv/lib/python3.7/site-packages/twilio/base/version.py", line 209, in create
raise self.exception(method, uri, response, 'Unable to create record')
twilio.base.exceptions.TwilioRestException:
HTTP Error Your request was:
POST /Accounts/AC04081c1b40.....532f/Messages.json
Twilio returned the following information:
Unable to create record: Authenticate
More information may be available here:
https://www.twilio.com/docs/errors/20003
Will continue dev in https://github.com/kontrasband/stats/blob/master/notebooks/Whatsapp.ipynb
Get going using twillio's WhatsApp API: https://www.twilio.com/blog/send-whatsapp-message-30-seconds-python