I have an asp.net core (3.1) web api with an endpoint to accept the Twilio Messaging Webhook. When I run it locally from postman it works, when the webhook posts, I get an 415 "Unsupported Media Type"
[ApiController]
[Route("[controller]")]
public class TwillioController : TwilioController
{
[HttpPost("ProcessIncomingMessage")]
public TwiMLResult ProcessIncomingMessage(SmsRequest incomingMessage)
{
Console.WriteLine($"Recieved new SMS from {incomingMessage.From}");
var messagingResponse = new MessagingResponse();
messagingResponse.Message("The copy cat says: " +
incomingMessage.Body);
return TwiML(messagingResponse);
}
}
It works when I have Content-Type:application/json in the header in postman.
I have also tried adding
[Consumes("application/x-www-form-urlencoded")]
as well as
[Consumes("application/xml")]
and both still get the unsupported media type... can not figure out what Twilio is sending over or what I need to do to make it compatibly with their webhook.