Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将内容类型添加到Twilio响应?_Twilio_Asp.net Web Api - Fatal编程技术网

如何将内容类型添加到Twilio响应?

如何将内容类型添加到Twilio响应?,twilio,asp.net-web-api,Twilio,Asp.net Web Api,如何将内容类型添加到Twilio响应?我收到502错误网关,错误表明可能是因为缺少内容类型。但我确实看到了响应的内容类型。那么会出什么问题呢?我也看到了twilio的原因是连接超时!这是什么意思?这与我之前的帖子有关: Content-Type text/html位指的是502错误网关响应,而不是来自服务器的实际响应。将“text/xml”内容类型添加到您的请求中(我不知道您正在使用的框架),您应该可以开始了 要调试您的响应,您可以使用curl-vvv[URL],直到内容类型:text/xml部

如何将内容类型添加到Twilio响应?我收到502错误网关,错误表明可能是因为缺少内容类型。但我确实看到了响应的内容类型。那么会出什么问题呢?我也看到了twilio的原因是连接超时!这是什么意思?这与我之前的帖子有关:


Content-Type text/html
位指的是502错误网关响应,而不是来自服务器的实际响应。将“text/xml”内容类型添加到您的请求中(我不知道您正在使用的框架),您应该可以开始了


要调试您的响应,您可以使用
curl-vvv[URL]
,直到
内容类型:text/xml
部分出现。

我仍然被卡住,而Twilio仍然给出错误。任何指点都将不胜感激。谢谢。以上代码至少正确吗?
 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>
      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);
        } 
    }