Forum Cross Platform with Xamarin

'System.Net.WebRequest' does not contain a definition for "GetRequestStream"

I am trying to get XML data from a Web Service on a Portable project and I am getting the above error for several methods for my request variable.
The methods that get this error are ASCIIEncoding, ContentLength, GetRequestStream, Close, and GetResponse.
Ideally, I would like to use this method because I know that it works on a simple console application, but what would other work around would you suggest?

private string DoRequest(string URL, string RequestString)
{
byte[] bytes = new ASCIIEncoding().GetBytes(RequestString);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytes.Length;

        Stream requestStream = request.GetRequestStream();
        requestStream.Write(bytes, 0, bytes.Length);
        requestStream.Close();

        WebResponse response = request.GetResponse();
        string responseXml = string.Empty;
        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            responseXml = reader.ReadToEnd();

        return responseXml;
}

Answers

Sign In or Register to comment.