I have code which I obtained in March this year for using the API-NG. But at some point in the intervening period it has stopped working. Is there anything which has changed since then and which leaps out as immediately obvious as an explanation of why my code no longer works? If not then perhaps I'd better start again from scratch.
I get an error at request.GetRequestStream - "Error occurred: 5 - The underlying connection was closed: An unexpected error occurred on a receive."
Thanks.
I get an error at request.GetRequestStream - "Error occurred: 5 - The underlying connection was closed: An unexpected error occurred on a receive."
Thanks.
Code:
Function SendRequest(ByVal Data) As String
On Error GoTo ErrorHandler
'Code is from here: http://www.betfairprotrader.co.uk/. Has started stalling when I try GetResponse as of 2 April.
Dim request As WebRequest = WebRequest.Create("https://api-ng.betstores.com/betting/betfair/services/api.betfair.com/exchange/betting/json-rpc/v1")
request.Method = "POST"
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes(Data)
request.ContentType = "application/json"
request.ContentLength = byteArray.Length
request.Headers.Add("X-Application: " & "***********") 'id I got for "betfair checker".
request.Headers.Add("X-Authentication: " & ssoid)
Dim dataStream As System.IO.Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Debug.Print(CType(response, HttpWebResponse).StatusDescription)
dataStream = response.GetResponseStream()
Dim reader As New System.IO.StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
Return responseFromServer
ErrorHandler:
HandleError()
End Function


Comment