I cannot seem to figure out how to call a Twilio function correctly. I tried calling it by passing data via POST:
url = "https://xxxx-dev.twil.io/voicemail"
data = {'event': {'id': '00141',
'RecordingUrl': 'https://api.twilio.com/2010-04-01/Accounts/ssssss/Recordings/xxxxxxx.mp3',
'From': '+12xxxxxxxxx',
'textTranslation': 'something here'}}
requests.post(url, data=data)
It doesn't seem to work. It returns 500 because it does not find the event object or the context object. How do I pass event, context, callback when calling a function directly?
Turns out I was sending the data incorrectly. You also don't need to include context nor callback, those are provided by twilio. You need to send only data as json to that endpoint.
url = "https://xxxx-dev.twil.io/voicemail"
data = {'id': '00141',
'RecordingUrl': 'https://api.twilio.com/2010-04-01/Accounts/ssssss/Recordings/xxxxxxx.mp3',
'From': '+12xxxxxxxxx',
'textTranslation': 'something here'}
requests.post(url, json=data)