Twilio Request Message

2019-07-25 04:45发布

I have configured my endpoint to which twilio will make a request when an SMS is received.

enter image description here

Below is my model which will accept twilio request.

public class TwilioRequest
    {
        public string MessageSid { get; set; }
        public string AccountSid { get; set; }
        public string From { get; set; }
        public string To { get; set; }
        public string Body { get; set; }
        public int NumMedia { get; set; }
        public List<string> MediaContentType { get; set; }
        public List<string> MediaUrl { get; set; }
    }

Below is my WEB API controller

public void POST([FromBody]TwilioRequest request)
        {
            Logger.Info("Hit");
            Logger.Info(string.Format("Account Sid {0}", request.AccountSid));
            Logger.Info(string.Format("Body {0}", request.Body));
            Logger.Info(string.Format("From {0}", request.From));
            Logger.Info(string.Format("MediaContentType {0}", request.MediaContentType));
            foreach (var i in request.MediaContentType)
            {
                Logger.Info(string.Format("MediaContent: {0}", i));
            }
            foreach (var i in request.MediaUrl)
            {
                Logger.Info(string.Format("MediaUrl {0}", i));
            }

            Logger.Info(string.Format("MessageSid {0}", request.MessageSid));
            Logger.Info(string.Format("NumMedia {0}", request.NumMedia));
            Logger.Info(string.Format("To {0}", request.To));
}

But it does not seem that twilio is hitting my end point. I am expecting a json. Kindly advice.

0条回答
登录 后发表回答