简体   繁体   English

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

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

I'm trying to do the following:我正在尝试执行以下操作:

  1. Call twilio #.拨打 twilio #。
  2. Gather digits from user.从用户那里收集数字。
  3. Process digits.处理数字。

I'm using DotNetCore webapi.我正在使用 DotNetCore webapi。

The problem I'm having is that when twilio posts to the Gather action uri, Digits is always null. I confirmed in the twilio debug console that the Digits parameter does have a value.我遇到的问题是,当 twilio 发布到 Gather 操作 uri 时,Digits 始终为 null。我在 twilio 调试控制台中确认 Digits 参数确实有一个值。

Here's a reduced version of my controller:这是我的 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");
    }
}

Also, I can copy the RAW parameters from the debug console into postman's parameters and successfully post to my endpoint.此外,我可以将调试控制台中的 RAW 参数复制到邮递员的参数中,并成功发布到我的端点。

Am I missing something?我错过了什么吗? Maybe some decoration on the JoinMeeting method?也许对 JoinMeeting 方法进行一些修饰?

I failed to read the manual...我没看说明书。。。

On twilio POST, parameters will be in the body.在 twilio POST 中,参数将在正文中。

On twilio GET, parameters will be in the query string.在 twilio GET 上,参数将在查询字符串中。

I updated the 2nd method to GET and made sure to specify the method:我将第二种方法更新为 GET 并确保指定方法:

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

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

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