简体   繁体   中英

How to handle my sms statuscallback in twilio using .net mvc?

this is my api url call from my application:

statusCallback: new Uri("http://xx.xx.xx.xx:xx/api/SMSAPI"/>

this is what i tried in my API:

    [HttpPost]
    public void Post([FromBody]string value)
    {
        string MessageStatus="From Body: " + value;
        //return statusText;
        printLog(MessageStatus);

    }

where printLog() writes data in log file. but the problem is it prints only "From Body:" so how to get all values from twilio

Also it gives error 500 in twilio console... image

Twilio evangelist here.

Twilio passes parameters as form encoded values, so you can specify the names of those individual parameters as your method parameters to let ASP.NET automatically map them:

public void Post([FromBody]string To, [FromBody]string From, [FromBody]string Body)

Or you can use the twilio-aspnet Nuget package to map them all into a single strongly typed object:

public void Post(SmsRequest request)

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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