none
Unable to connect to the remote server RRS feed

  • 問題

  • Hi there,
    I have an outlook addin and get ready to connect Azure API, I list out the code for you to look at. When the code runs to this line:
    > using (Stream requestStream = webapiRequest.GetRequestStream())
    it shows me the error message "Unable to connect to the remote server" ... Does anyone have any idea on it.??
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        byte[] bytes = Encoding.UTF8.GetBytes(postData);
       
        var webapiUriRequest = (HttpWebRequest)WebRequest.Create(new Uri(WebAPIUrl));
       
        var webapiRequest = (HttpWebRequest)webapiUriRequest;
        webapiRequest.PreAuthenticate = true;
        webapiRequest.Headers.Add("Authorization",
        Convert.ToBase64String(Encoding.UTF8.GetBytes(WebAPIAccessAccount + ":" + WebAPIAccessPassword)));
        webapiRequest.Method = "POST";
        webapiRequest.ContentType = "application/json";
        webapiRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
        webapiRequest.KeepAlive = false;
       
        using (Stream requestStream = webapiRequest.GetRequestStream())
        {
            requestStream.Write(bytes, 0, bytes.Count());
        }
       
       using (HttpWebResponse webapiResponse = (HttpWebResponse)webapiRequest.GetResponse())
       {
          if (webapiResponse.StatusCode != HttpStatusCode.OK)
          {
              throw new ApplicationException(webapiResponse.StatusCode.ToString());
          }
       }

    Hi there, if you found my comment very helpful then please | Propose as answer | . Thanks and Regards.

    2020年1月8日 下午 04:18

所有回覆

  • Hi Will.H,

    Welcome to MSDN forum.

    According to your description and the attached code, I suppose the issue is about outlook addin development, and our forum is to discuss the Visual Studio IDE and I will help you move this thread to a better support forum.

    If you have any more Visual Studio General Questions issues in the future, please feel free to let us know.

    Thanks for your understanding.

    Best Regards,

    Anna


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    2020年1月9日 上午 03:30