Hi Guys,
I am slowly learning programing (at the age of 64), and was given a simple guide for creating a "Betfair Bot".
Unfortunately, large parts of the book are out of date, and much of the code needs modified before it will work.
I managed to create my self-certificate and upload it ok, but I am now struggling to get my test bot to log into the site.
My code is as follows:
My PC returns the follwoing:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\WINDOWS\system32>
Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 1 Keys:
Ctrl+v
Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -38.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
Invoke-WebRequest : Missing an argument for parameter 'Uri'. Specify a parameter of type 'System.Uri' and try again.
At line:28 char:26
+ $RET = invoke-webrequest -uri
+ ~~~~
+ CategoryInfo : InvalidArgument: (
[Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.Invo keWebRequestCommand
https://identitysso-cert.betfair.com/api/certlogin : The term 'https://identitysso-cert.betfair.com/api/certlogin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.
At line:29 char:1
+ https://identitysso-cert.betfair.com/api/certlogin -Certificate $cert ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (https://identit...m/api/certlogin:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
body : The term 'body' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:30 char:1
+ body $postParams -Headers @{"X-Application"="RD_BETFAIR_BOT"} -
+ ~~~~
+ CategoryInfo : ObjectNotFound: (body:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ContentType : The term 'ContentType' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:31 char:1
+ ContentType "application/x-www-form-urlencoded"
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (ContentType:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At line:32 char:8
+ $RET | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (
[ConvertFrom-Json], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Mic rosoft.PowerShell.Commands.ConvertFromJsonCommand
I am guessing that the above is more than just a simple syntax error, but I am at a loss as to how to fix it.
I have tried various varients of the above code, but still get the same errors.
The myusername, mypassword & mybot replace the actual data. Other than that the code is unchanged.
Are there any gurus out there who can give a young-at-heart 64 year old some pointers?
Many thanks.
Best wishes.
Pete
I am slowly learning programing (at the age of 64), and was given a simple guide for creating a "Betfair Bot".
Unfortunately, large parts of the book are out of date, and much of the code needs modified before it will work.
I managed to create my self-certificate and upload it ok, but I am now struggling to get my test bot to log into the site.
My code is as follows:
Code:
####################
# Function Section #
####################
###############################
# Get Self Signed Certificate #
###############################
Function get-cert {get-pfxcertificate -filepath "c:\Program Files\OpenSSL-Win64\bin\client.p12"}
###################################################################
# Logs in and receives session token used for all remaining calls #
###################################################################
Function login {
$postParams = @{username='[I]myusername[/I]';password='[I]mypassword[/I]'}
$thumbprint = $cert.Thumbprint
$RET = invoke-webrequest -uri
https://identitysso-cert.betfair.com/api/certlogin -Certificate $cert -Method Post -
body $postParams -Headers @{"X-Application"="[I]mybot[/I]"} -
ContentType "application/x-www-form-urlencoded"
$RET | ConvertFrom-Json
}
#####################
# Main Code Section #
#####################
$cert= get-cert # Certificate
$Ret = login $cert # Login
My PC returns the follwoing:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\WINDOWS\system32>
Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 1 Keys:
Ctrl+v
Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -38.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
Invoke-WebRequest : Missing an argument for parameter 'Uri'. Specify a parameter of type 'System.Uri' and try again.
At line:28 char:26
+ $RET = invoke-webrequest -uri
+ ~~~~
+ CategoryInfo : InvalidArgument: (
[Invoke-WebRequest], ParameterBindingException+ FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.Invo keWebRequestCommand
https://identitysso-cert.betfair.com/api/certlogin : The term 'https://identitysso-cert.betfair.com/api/certlogin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.
At line:29 char:1
+ https://identitysso-cert.betfair.com/api/certlogin -Certificate $cert ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (https://identit...m/api/certlogin:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
body : The term 'body' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:30 char:1
+ body $postParams -Headers @{"X-Application"="RD_BETFAIR_BOT"} -
+ ~~~~
+ CategoryInfo : ObjectNotFound: (body:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ContentType : The term 'ContentType' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:31 char:1
+ ContentType "application/x-www-form-urlencoded"
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (ContentType:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At line:32 char:8
+ $RET | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (
[ConvertFrom-Json], ParameterBindingValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Mic rosoft.PowerShell.Commands.ConvertFromJsonCommand
I am guessing that the above is more than just a simple syntax error, but I am at a loss as to how to fix it.
I have tried various varients of the above code, but still get the same errors.
The myusername, mypassword & mybot replace the actual data. Other than that the code is unchanged.
Are there any gurus out there who can give a young-at-heart 64 year old some pointers?
Many thanks.
Best wishes.
Pete


Comment