我正在使用以下代码在我的 .net 核心 api 中接收发送到 Twilio 虚拟号码的短信。我的 web hook api 代码是这样的,
namespace MyNameSpace.Controllers
{
[Route(Routing.CONTROLLER_PREFIX)]
public class MfaController : MyControllerBase
{
[HttpPost]
[Route(Constants.Save)]
[Produces("application/xml")]
public ActionResult SaveText(TextMessage TextInfo)
{
// My save logic here
return Ok();
}
}
}
当我在本地测试代码时,我在提琴手和邮递员中得到 200 - Ok 响应。但我在 Twilio 控制台(调试器)中遇到错误
{
"callbackResult": "SUCCESS",
"statusCode": 502,
"body": "VHd...............",
"cookies": [],
"headers": {
"Transfer-Encoding": [
"chunked"
],
"X-Cache": [
"MISS from ip-XXX-18-0-xXx"
],
"X-Cache-Lookup": [
"MISS from ip-XXX-18-0-XXX:3128"
],
"X-Twilio-Reason": [
"Response does not contain content type"
],
"Date": [
"Thu, 29 Mar 2018 16:08:10 GMT"
],
"Content-Type": [
"text/html"
]
}
}
API 的响应类型应该是什么?我不需要向用户发送回复消息,只需要保存短信。