Unable to connect to the remote server RRS feed

  • Question

  • 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;
        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.

    Wednesday, January 8, 2020 4:18 PM

All replies

  • 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,


    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

    Thursday, January 9, 2020 3:30 AM