I am using Twilio Python SDK for verify services. I get below error when I try to send email OTPs.
{TwilioRestException}HTTP 404 error: Unable to create record: The requested resource
/Services/VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Verifications was not found
Below is my Python code to perform this task:
from twilio.rest import Client
client = Client('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', AUTH_TOKEN)
verification = self.client.verify.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')\
.verifications\
.create(to='example@gmail.com', channel='email')
When I use CURL to send request then it happens successfully and I receive the mail with the verify code.
curl -X POST https://verify.twilio.com/v2/Services/VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Verifications \
--data-urlencode "To=example@gmail.com" \
--data-urlencode "Channel=email" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
The above POST call in POSTMAN gives me the below URL:
https://verify.twilio.com/v2/Services/VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Verifications/VEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
when I click on that URL that same error is thrown up as it was shown from Python SDK.
Note: But from POSTMAN I am getting receiving Email but not from Python SDK.
Why am I getting the above mentioned error in Python, even after following the steps of DOCS. https://www.twilio.com/docs/verify/email?code-sample=code-check-an-email-verification&code-language=Python&code-sdk-version=6.x#create-a-sendgrid-api-key
Twilio developer evangelist here.
We spoke privately about this question. It turned out that Vijay was using the Twilio Python library version 6.20.0.
I recommended upgrading to the latest version of Twilio Python, 6.41.0 (as I write this), and that fixed the issue.