Yesterday I downloaded the Github API-NG C# Sample Code to get the latest changes.
I noticed a few issues that Betfair might want to look into. (they are quick and easy to resolve)
Issue 1) Using Visual Studio 2022 the C# solution source doesnt build for me.
Issue 2) A Bet is placed that according to example code shouldnt work.
The code tries to place a bet of £ 0.10 at odds of 1000.
It prints out to console "Below minimum betsize and expecting a INVALID_BET_SIZE response"
I was expecting that error as 10 pence is less than the minimum bet size of £1.00, however it works and the bet does actually get placed.
So the code is not behaving as the console priint out says it should. i havent figured out the exact reason why that works, but I am guessing it has to do with the changes that were made some time back to prevent some rounding error exploit on small bet stakes. Cant remember details now, but would be interested to know if anyone understands this one ?
Issue 3)
I noticed that the version of Newtonsoft.json.dll in the repo is version 4.5.10 which is ancient. Apparently this dll had security vulnerabilties all the way up to versions 13.0.1
In the repo version Betfair havent used the nuget package for this dll Betfair should probably consider updating this dll for security reasons. I tried deleting the old one in the lib folder and adding version 13.3 via nuget package. As far as I can see it is now using the latest dll and didnt introduce any build problems.
While I am writing this up, a cople of simple suggestions that I think would be an improvement to the code.
Suggestion 1)
Before I got this working, program.cs was exiting with various errors, I couldnt quickly see what the error was as the console window closes before you can read the output. In all the error exit points consider changing to
Suggestion 2)
When I was testing this if I ran code more than once quickly I got an error referring to duplicate bets. This was initially puzzling but was down to this line
So that makes sense, but to stop this error popping up it maybe better to change it to this.
Suggestion 3)
As the code can handle zipped responses from Betfair, why not enable that in the example ? Consider adding to jsonRpcClient.cs
Sorry for long post, hope it was of some use
I noticed a few issues that Betfair might want to look into. (they are quick and easy to resolve)
Issue 1) Using Visual Studio 2022 the C# solution source doesnt build for me.
Code:
In JsonRPCclient.cs if (response.ContentEncoding.ToLower() == "gzip") // ContentEncoding is not known Presumably this is now deprecated in Net 4.8 version. I fixed it with string contentEncoding = response.Headers["Content-Encoding"]; if(contentEncoding?.ToLower() == "gzip")
The code tries to place a bet of £ 0.10 at odds of 1000.
It prints out to console "Below minimum betsize and expecting a INVALID_BET_SIZE response"
I was expecting that error as 10 pence is less than the minimum bet size of £1.00, however it works and the bet does actually get placed.
So the code is not behaving as the console priint out says it should. i havent figured out the exact reason why that works, but I am guessing it has to do with the changes that were made some time back to prevent some rounding error exploit on small bet stakes. Cant remember details now, but would be interested to know if anyone understands this one ?
Issue 3)
I noticed that the version of Newtonsoft.json.dll in the repo is version 4.5.10 which is ancient. Apparently this dll had security vulnerabilties all the way up to versions 13.0.1
In the repo version Betfair havent used the nuget package for this dll Betfair should probably consider updating this dll for security reasons. I tried deleting the old one in the lib folder and adding version 13.3 via nuget package. As far as I can see it is now using the latest dll and didnt introduce any build problems.
While I am writing this up, a cople of simple suggestions that I think would be an improvement to the code.
Suggestion 1)
Before I got this working, program.cs was exiting with various errors, I couldnt quickly see what the error was as the console window closes before you can read the output. In all the error exit points consider changing to
Code:
Console.ReadKey(); Environment.Exit(0);
Suggestion 2)
When I was testing this if I ran code more than once quickly I got an error referring to duplicate bets. This was initially puzzling but was down to this line
Code:
var customerRef = "123456";
Code:
// mS to randomise a bit, as duplicates will make Betfair return a duplicate bet error var customerRef = "123456" + DateTime.Now.Millisecond;
Suggestion 3)
As the code can handle zipped responses from Betfair, why not enable that in the example ? Consider adding to jsonRpcClient.cs
Code:
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip");
Sorry for long post, hope it was of some use


Comment