通过 REST API 删除短信和语音的 Twilio 演示 URL
我正在尝试弄清楚如何[更新] IncomingPhoneNumber 以删除购买电话号码时为语音和短信设置的“演示”Url。
例如,我的 VoiceUrl 在 Twilio UI 控制台中设置为“https://demo.twilio.com/welcome/voice/”。我知道我可以从控制台中删除它,但我希望有一种方法可以从 REST 服务(例如通过 IncomingPhoneNumberResource.Update)设置它?
I'm trying to figure out how I can [update] the IncomingPhoneNumber to remove the 'Demo' Url set for Voice and Sms when a phone number is purchased.
For example my VoiceUrl is set to "https://demo.twilio.com/welcome/voice/" in the Twilio UI console. I know I can just remove it from the console but I am hoping there is a way that I can set it from a REST Service such as through the IncomingPhoneNumberResource.Update?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:
我正在做 PR 来改善这种体验,并偶然发现了库中已有的解决方案。
有一个类型
Twilio.Types.EmptyUri
继承自System.Uri
。当您传递该类型的实例来更新电话号码上的 URL 时,它将清空/使 URL 字段为空。
旧答案:
您可能已经注意到,您无法使用
IncomingPhoneNumberResource.Update
方法删除 URL。Twilio .NET 库中
voiceUrl
和smsUrl
的默认值为null
,因此如果您显式传入null
code>,库不会知道差异并忽略它。幸运的是,REST API 非常直观,因此您可以编写自己的代码来进行 REST API 调用,或者使用 Twilio .NET 库附带的
RestClient
。以下是不起作用的
IncomingPhoneNumberResource.Update
和使用RestClient
起作用的代码的示例。Update:
I was working on a PR to make this experience better and stumbled on a solution that's already in the library.
There's a type
Twilio.Types.EmptyUri
which inherits fromSystem.Uri
.When you pass an instance of the type to update URLs on a phone number, it'll empty/null the URL field.
Old answer:
As you may have noticed, you cannot remove the URL using the
IncomingPhoneNumberResource.Update
method.The default value of the
voiceUrl
andsmsUrl
in the Twilio .NET library isnull
, so if you explicitly pass innull
, the library won't know the difference and ignore it.Luckily, the REST API is quite intuitive, so you can write your own code to make REST API calls, or use the
RestClient
that comes with the Twilio .NET library.Here's an example of both the
IncomingPhoneNumberResource.Update
that doesn't work, and the code that does work using theRestClient
.