Hi
I'm getting an error in my code. It was working a while ago, but for some reason I can't seem to see where it might be wrong now.
Thanks
try
{
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.betfair.com/exchange/betting/json-rpc/v1");
if (MyProxy != null)
{
httpWebRequest.Proxy = MyProxy;
}
NameValueCollection CustomHeaders = new NameValueCollection();
CustomHeaders["X-Application"] = AppKey;
CustomHeaders["X-Authentication"] = SessionToken;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Accept = "application/json";
httpWebRequest.Method = WebRequestMethods.Http.Post;
httpWebRequest.Headers.Add(HttpRequestHeader.Accep tCharset, "ISO-8859-1,utf-8");
httpWebRequest.Headers.Add(CustomHeaders);
Byte[] BA = Encoding.UTF8.GetBytes(Output);
httpWebRequest.ContentLength = BA.Length;
Stream SW = httpWebRequest.GetRequestStream();
SW.Write(BA, 0, BA.Length);
------- Failing here
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream Reader = httpResponse.GetResponseStream();
StreamReader Sreader = new StreamReader(Reader);
String IN = Sreader.ReadToEnd();
return IN;
}
catch (Exception e)
{
return "ERROR : " + e.ToString();
}
I'm getting an error in my code. It was working a while ago, but for some reason I can't seem to see where it might be wrong now.
Thanks
try
{
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.betfair.com/exchange/betting/json-rpc/v1");
if (MyProxy != null)
{
httpWebRequest.Proxy = MyProxy;
}
NameValueCollection CustomHeaders = new NameValueCollection();
CustomHeaders["X-Application"] = AppKey;
CustomHeaders["X-Authentication"] = SessionToken;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Accept = "application/json";
httpWebRequest.Method = WebRequestMethods.Http.Post;
httpWebRequest.Headers.Add(HttpRequestHeader.Accep tCharset, "ISO-8859-1,utf-8");
httpWebRequest.Headers.Add(CustomHeaders);
Byte[] BA = Encoding.UTF8.GetBytes(Output);
httpWebRequest.ContentLength = BA.Length;
Stream SW = httpWebRequest.GetRequestStream();
SW.Write(BA, 0, BA.Length);
------- Failing here
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream Reader = httpResponse.GetResponseStream();
StreamReader Sreader = new StreamReader(Reader);
String IN = Sreader.ReadToEnd();
return IN;
}
catch (Exception e)
{
return "ERROR : " + e.ToString();
}


Comment