最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Twilio C# ASP.NET Core Web API project recordingStatusCallback keeps returning a status 400. What am I doing wrong? - Stack Over

programmeradmin8浏览0评论

I'm building an application where I want the call recordings URL and duration of the call captured upon completion of the call.

My recordingStatusCallback handler requests keep returning with a status 400 and I don't know why it is doing that or how I could debug this further.

Here is my Recordings handler:

[HttpPost]
public void Recordings([FromForm] VoiceRequest request)
{
    // TODO: Get the recording URL and log it to the database for the call 
    Console.WriteLine($"CallSID: {request.CallSid}");
    Console.WriteLine($"RecordingUrl: {request.RecordingUrl}");
    Console.WriteLine($"RecordingDuration: {request.RecordingDuration}");

    // Not sure what happens here... testing it out if transcriptions are available... 
    Console.WriteLine($"TranscriptionUrl: {request.TranscriptionUrl}");
}

For reference, I have a similar handler for statusCallbackEvent - see this snippet:

[HttpPost]
public void Events([FromForm] VoiceRequest request)
{
    Console.WriteLine($"CallSID: {request.CallSid}");
    
    Console.WriteLine($"CallStatus: {request.CallStatus}");

    Console.WriteLine($"DialCallDuration: {request.DialCallDuration}");
}

And this Events function is being called correctly without issues.

I'd appreciate your help!

I'm building an application where I want the call recordings URL and duration of the call captured upon completion of the call.

My recordingStatusCallback handler requests keep returning with a status 400 and I don't know why it is doing that or how I could debug this further.

Here is my Recordings handler:

[HttpPost]
public void Recordings([FromForm] VoiceRequest request)
{
    // TODO: Get the recording URL and log it to the database for the call 
    Console.WriteLine($"CallSID: {request.CallSid}");
    Console.WriteLine($"RecordingUrl: {request.RecordingUrl}");
    Console.WriteLine($"RecordingDuration: {request.RecordingDuration}");

    // Not sure what happens here... testing it out if transcriptions are available... 
    Console.WriteLine($"TranscriptionUrl: {request.TranscriptionUrl}");
}

For reference, I have a similar handler for statusCallbackEvent - see this snippet:

[HttpPost]
public void Events([FromForm] VoiceRequest request)
{
    Console.WriteLine($"CallSID: {request.CallSid}");
    
    Console.WriteLine($"CallStatus: {request.CallStatus}");

    Console.WriteLine($"DialCallDuration: {request.DialCallDuration}");
}

And this Events function is being called correctly without issues.

I'd appreciate your help!

Share Improve this question edited Mar 12 at 21:15 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 12 at 21:01 punsandgunspunsandguns 693 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

After lots of trial and error, I stumbled upon the solution to my problem. For whatever reason, the statusCallback and the recordingStatusCallback are not treated the same. The handler that eventually does work for me is as below

public async System.Threading.Tasks.Task RecordingsAsync()
{
    // TODO: Get the recording URL and log it to the database for the call 
    var form = await Request.ReadFormAsync();

    Console.WriteLine($"CallSid: {form["CallSid"]}");
    Console.WriteLine($"RecordingUrl: {form["RecordingUrl"]}");
    Console.WriteLine($"RecordingDuration: {form["RecordingDuration"]}");
}

I'm only accessing 3 values here but there are more parameters you can access - read about them here https://www.twilio/docs/voice/api/call-resource#parameters-sent-to-your-recordingstatuscallback-url

I would still like a Twilio expert to comment on whether my solution is the right way to do this or if there is a better-prescribed approach that should be considered.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论