joelpob / betfairng

C# API for Betfair API-NG
MIT License
38 stars 37 forks source link

BetfairClient.Login fails with INVALID_USERNAME_OR_PASSWORD #14

Open Stereocheck opened 7 years ago

Stereocheck commented 7 years ago

Great work on the Library!

When I try do a non-interactive Login with BetfairClient.Login if fails with INVALID_USERNAME_OR_PASSWORD even though they are correct. Looking into this it seems the code for generating the post data does not correctly format the details as a URL formatted string. My password has several nonstandard characters in it which seem to be misinterpreted during login.

I replaced the following code: string postData = string.Format("username={0}&password={1}", username, password);

with:

NameValueCollection outgoingQueryString = HttpUtility.ParseQueryString(String.Empty); outgoingQueryString.Add("username", username); outgoingQueryString.Add("password", password); string postData = outgoingQueryString.ToString();

Which rectifies the problem and logs in successfully. There may be more succinct ways of achieving this but this worked for me.

Cheers.