Would be great to extend SmsRequest class wrapping the Twilio POST webhook request for incoming MMS with the property bound to media files collection. Now to retrieve the media files from Twilio webhook call on ASP.NET Core API (while I am getting incoming MMS from external phone number) I have to read from Request.Form to retrieve media related parameters.
[HttpPost("message")]
[AllowAnonymous]
public async Task<TwiMLResult> MessageWebhook(SmsRequest request, CancellationToken token) {
...
for (int i = 0; i < request.NumMedia; i++)
{
string? mediaUrl = Request.Form[$"MediaUrl{i}"];
string? contentType = Request.Form[$"MediaContentType{i}"];
...
}
}
Would be great to just mark SmsRequest request as [FromForm] SmsRequest request and access media related items like this:
List<MediaFile> mediaFiles = request.MediaFiles;
So ASP.NET Core controller for handling SMS/MMS webhooks woul dlook like this:
using Twilio.AspNet.Common;
using Twilio.AspNet.Core; // or .Mvc for .NET Framework
using Twilio.TwiML;
public class WebhookController : TwilioController
{
[HttpPost("message")]
[AllowAnonymous]
public async Task<TwiMLResult> MessageWebhook([FromForm] SmsRequest request, CancellationToken token) {
...
foreach (var media in request.MediaFiles)
{
string mediaUrl = media.Url;
string contentType = media.ContentType;
}
...
}
}
Would be great to extend
SmsRequest
class wrapping the Twilio POST webhook request for incoming MMS with the property bound to media files collection. Now to retrieve the media files from Twilio webhook call onASP.NET Core
API (while I am getting incoming MMS from external phone number) I have to read fromRequest.Form
to retrieve media related parameters.Would be great to just mark
SmsRequest
request as[FromForm] SmsRequest request
and access media related items like this:List<MediaFile> mediaFiles = request.MediaFiles;
So
ASP.NET Core
controller for handling SMS/MMS webhooks woul dlook like this:using Twilio.AspNet.Common; using Twilio.AspNet.Core; // or .Mvc for .NET Framework using Twilio.TwiML;