Reputation: 123
This code to throws Twilio.Exceptions.ApiException Url is not a valid URL:
var call = CallResource.Create(
url: new Uri("https://localhost:44300/TwimlResponse.ashx?code=87359179"),
to: new Twilio.Types.PhoneNumber("+16509661950"),
from: new Twilio.Types.PhoneNumber(phonenumber)
);
This is a perfectly valid url. I do not understand why this exception is being thrown? Can't the webhook url make a call to ashx page on a specific port number?
Upvotes: 2
Views: 313
Reputation: 73027
The webhook URL can make requests to a page on a specific port number. What it cannot do is make requests to your localhost.
You need to expose that localhost URL to the public internet somehow. One way is by using a tunnelling service. I personally like to use ngrok to do this.
You can use ngrok by downloading it then, in this case, calling
ngrok http 44300
If you are running Windows, then you may need more detail available in the Twilio documentation.
Once you have ngrok running and forwarding to your localhost port, you will be given a URL that looks like https://RANDOM_SUBDOMAIN.ngrok.io
and you can use that URL in place of localhost:44300
as above.
Upvotes: 1