如何将内容类型添加到 Twilio 响应?我收到 502 bad gateway 错误,该错误表示可能是因为缺少 Content-Type。但我确实看到响应具有内容类型。那么可能出了什么问题呢?我也看到 twilio 原因是连接超时!这意味着什么?这与我之前的帖子有关:尝试从返回的 HTTP 状态代码 502 中检索内容。请检查 URL 并重试
Response - The HTTP headers and body of your server's response to Twilio
Headers
Content-Type text/html
Transfer-Encoding chunked
X-Twilio-Reason connection timed out
Body
1
<html><head><title>502 Bad Gateway</title></head><body><h1>Bad Gateway</h1>An upstream server returned an invalid response.</body></html>
有人可以帮我找出为什么 twilio 在访问我的 API 时会出错吗?这就是我的控制器中的内容:
public class TestController : ApiController
{
[HttpPost]
public HttpResponseMessage Post([FromBody]SmsRequest smsReq)
{
string smsReqUpper = smsReq.Body.ToUpper();
string testString = "TEST";
var response = new Twilio.TwiML.TwilioResponse();
if (smsReqUpper == testString)
{
response.Sms("Test Successful");
return Request.CreateResponse(HttpStatusCode.OK, response.Element);
}
else
{
string strBody = "Invalid Text Command. Please text the word TEST " ;
response.Sms(strBody);
return Request.CreateResponse(HttpStatusCode.OK, response.Element);
//return new TwiMLResult(response);
}
}