I've recently returned to working on my application after quite a break. For some reason, code that was previously working is now returning a 400:Bad Request error when I try to log into the betfair api.
My code is
var postData = $"userName={userName}&password={password}";
var x509Certificate = new X509Certificate2(p12CertificateLocation, p12CertificatePassword);
var request = (HttpWebRequest) WebRequest.Create("https://identitysso-api.betfair.com/api/certlogin");
request.UseDefaultCredentials = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add("X-Application", _appKey);
request.ClientCertificates.Add(x509Certificate);
request.Accept = "*/*";
request.Proxy = null;
using (var stream = request.GetRequestStream())
{
using (var writer = new StreamWriter(stream, Encoding.Default))
{
await writer.WriteAsync(postData).ConfigureAwait(false);
}
}
var response = await request.GetResponseAsync().ConfigureAwait(false);
Does anyone have any suggestions how to fix this?
My code is
var postData = $"userName={userName}&password={password}";
var x509Certificate = new X509Certificate2(p12CertificateLocation, p12CertificatePassword);
var request = (HttpWebRequest) WebRequest.Create("https://identitysso-api.betfair.com/api/certlogin");
request.UseDefaultCredentials = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add("X-Application", _appKey);
request.ClientCertificates.Add(x509Certificate);
request.Accept = "*/*";
request.Proxy = null;
using (var stream = request.GetRequestStream())
{
using (var writer = new StreamWriter(stream, Encoding.Default))
{
await writer.WriteAsync(postData).ConfigureAwait(false);
}
}
var response = await request.GetResponseAsync().ConfigureAwait(false);
Does anyone have any suggestions how to fix this?


Comment