My Bertfair Bot has been ticking along now for some time. However, in recent months - and more prevalent lately - I am getting INVALID_SESSION_INFORMATION errors, the result of which is that my program doesn't connect to the Betfair site. I've tweaked the code once in a while, but not touched the Session ID and Application Key part.
If I go into the demo app online, I can see the application key, which is the same as that in the program. Has something changed recently, can anyone tell me, or is there something I need to do to the code? It's getting very annoying!
Having looked at the code and debug, it appears that the SSOID is blank. The response is prefixed by wsid.
This is my code, which I got some time ago from the forum:
' initialise ssoid. This is used to get the Session Token information and needs to be reset if there are issues ssoid = ""
' Connect to betfair Dim uri As String = String.Format("https://identitysso.betfair.com/api/login?username={0}&passwo... sUsername, sPassword) Dim myRequest As HttpWebRequest = DirectCast(WebRequest.Create(uri), HttpWebRequest) myRequest.Method = "POST" myRequest.Timeout = 50000 Dim thePage As WebResponse = myRequest.GetResponse() info = thePage.Headers.GetValues("Set-Cookie") Dim i As Integer = 0 While ssoid = [String].Empty AndAlso i < info.Length If info(i).Contains("ssoid=") Then ssoid = info(i) End If i += 1 End While
Having looked at the code and debug, it appears that the SSOID is blank. The response is prefixed by wsid.This is my code, which I got some time ago from the forum: ' initialise ssoid. This is used to get the Session Token information and
It appears that I had something similar in the past.
As far as I can recall, when my program attempts to log in, for some reason it goes through the cookie code twice. The first time might be some sort of initialisation. I've had this kind of thing happen in a few sections in VB.NET. If I remember correctly, code that is triggered by a particular event seems to get triggered during initialisation - not by the specified event - and then again, later, when the actual event fires. I don't understand why, but I can tell you how I dealt with it in this instance.
My program is in VB.NET. My code where the cookies are checked is in a subroutine called WebBrowser1_DocumentCompleted.
First, it checks the cookies in a loop similar to yours.
Next, it deals with the ssoid, but ONLY IF THE SSOID IS NOT BLANK. If the ssoid is blank, the subroutine ends. The next time the subroutine is entered, the ssoid is not blank, and therefore relevant initialisation and transfer of control happens. This is my code subsequent to the cookie check, but with some removed where it sends a message to the main program (to display the ssoid on a messages tab):
If Not ssoid = "" Then Form1.ssoid = ssoid ' copy ssoid to main form variable ' next two lines store the ssoid as a text file for when the prog is next restarted Dim ssoidFileName As String = "ssoidFile.txt" My.Computer.FileSystem.WriteAllText(ssoidFileName, ssoid, False) ' Form1.Initialise() ' starts the ball rolling on the main form Me.Close() ' login window no longer required End If
End Sub
It appears that I had something similar in the past.As far as I can recall, when my program attempts to log in, for some reason it goes through the cookie code twice. The first time might be some sort of initialisation. I've had this kind of thing ha
I believe that I have got to the bottom of the issue. It seems to be occuring when too much data is requested - this is the real error in this instance. I will modify the code to include checking for a blank ssoid as well.
Thanks for the reply, Jabe.I believe that I have got to the bottom of the issue. It seems to be occuring when too much data is requested - this is the real error in this instance. I will modify the code to include checking for a blank ssoid as well.