繁体   English   中英

Twilio语音<gather> - DotNetCore - 数字参数始终为 null</gather>

[英]Twilio Voice <Gather> - DotNetCore - Digits parameter always null

我正在尝试执行以下操作:

  1. 拨打 twilio #。
  2. 从用户那里收集数字。
  3. 处理数字。

我正在使用 DotNetCore webapi。

我遇到的问题是,当 twilio 发布到 Gather 操作 uri 时,Digits 始终为 null。我在 twilio 调试控制台中确认 Digits 参数确实有一个值。

这是我的 controller 的简化版本:

[ApiController]
[Route("api/[controller]")]
public class VoiceController : ControllerBase
{
    [HttpPost]
    public IActionResult Post()
    {
        var response = new VoiceResponse();
        var say = new Say("Please type your meeting password.");
        var gather = new Gather(action: "placeholderURI/JoinMeeting");

        response.Append(gather).Append(say);
        response.Redirect("placeholderURI");

        return Content(response.ToString(), "application/xml");
    }

    [HttpPost("JoinMeeting")]
    public IActionResult JoinMeeting(string Digits)
    {
        var response = new VoiceResponse();
        
        if(Digits != null){
            //do stuff
        }else{
            var say = new Say("WRONG");
            response.Append(say).Redirect("placeholderURI");
        }
        
        return Content(response.ToString(), "application/xml");
    }
}

此外,我可以将调试控制台中的 RAW 参数复制到邮递员的参数中,并成功发布到我的端点。

我错过了什么吗? 也许对 JoinMeeting 方法进行一些修饰?

我没看说明书。。。

在 twilio POST 中,参数将在正文中。

在 twilio GET 上,参数将在查询字符串中。

我将第二种方法更新为 GET 并确保指定方法:

var gather = new Gather(action: "uriPlaceholder", method: HttpMethods.Get);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM