1
votes

I'm using Twilio api to send SMS and I'm specifying the StatusCallBackUrl to get the response from the Twilio when the SMS has been sent. The credential that I've been using are not test credentials. I want to know where I'm doing wrong because after I send the SMS I'm not getting the response from Twilio, however, I've enabled the cross-origin to accept the response from Twilio. I just console the response so that to know what are the structure of the response and what model it send the data.

This is my example call back URL:

public const String callBackUrl = "http://example.com/api/Reports/ProcessSmsResponse";

This is how I'm sending SMS through Twilio:

twilio = new Twilio.TwilioRestClient(this.TwilioAccount, this.TwilioAuthToken);

var message = twilio.SendMessage("+965478", "+987456", "test body", callBackUrl);

This the method which just print the SMS callback response:

[HttpPost]
public void ProcessSmsResponse()
{
    Logger.WriteLog(LogLevel.INFO, "ProcessSmsResponse");
    Logger.WriteLog(LogLevel.INFO, Request.Content);
}
1

1 Answers

3
votes

I was handling the request result in an in proper manner, the proper way is:

string queryString = Request.Content.ReadAsStringAsync().Result;

This would return me the queryString which Twilio posted to my action as callback response. Further, I just parsed the query string to get the query string parameter

var data = HttpUtility.ParseQueryString(queryString);

These are the parameter which I'm getting in Twilio SMSCallBack response: To, From, Body, SmsSid, SmsStatus, MessageSid, AccountSid, ApiVersion, MessageStatus, ErrorCode (it would be optional if there is any error we would get this parameter)

For ErrorCode refer to this link.