Hi All,
I am trying to integrate twilio with erpnext for sending SMS. It fails due to the auth issue
Below is frappe code where it fails link
gateway_url = https://[API KEY]:[TOKEN]@api.twilio.com/2010-04-01/Accounts/[API KEY]/Messages.json
headers = {u’From’: u’+1234567890’, u’Accept’: u’text/plain, text/html, /‘}
params = {u’Body’: ‘Example Message’, u’To’: u’91987654321’}
response = requests.post(gateway_url, headers=headers, data=params)
This fails with following error
‘HTTPError: 400 Client Error: BAD REQUEST for url’
To make it work, auth has to be corrected , following code worked
gateway_url=‘https://api.twilio.com/2010-04-01/Accounts/[API KEY]/Messages.json’
data = [(‘To’,‘+91987654321’),(‘From’,‘+1234567890’),(‘Body’,‘Success Test’),]
response = requests.post(gateway_url,data=data, auth=([API KEY],[TOKEN]))
To things required is To number has to have ‘+’ and auth to be passed to requests.post
My question, (a) How can i override requests.post of frappe link from my custom app
(b) Is there any way to correct frappe’s requests.post
Thanks!
@revant_one, any suggestions?! thanks