Hi All,
Am new to development for Betfair and am trying to create a list of horse racing UK races and runners with their Back and Lay prices displayed. I can get the course names and and runners etc...but am having an issue when trying to populate the prices...I keep getting error message "The remote server returned an error (400) Bad Request
I checked the URL and this seems to be correct -- https://api.betfair.com/exchange/betting/json-rpc/v1
Below is the code where I appear to be hitting the issue....any help would be greatly appreciated (I have removed my developer keys from the code below Request.Headers.Add
------------------------------------------
Private Function SendSportsReq(ByVal jsonString As String)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim request As HttpWebRequest =
WebRequest.Create _
("https://api.betfair.com/exchange/betting/json-rpc/v1")
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(jsonString)
Dim responseFromServer As String = ""
Try
request.Method = "POST"
request.ContentType = "application/json"
request.ContentLength = byteArray.Length
request.Headers.Add("X-Application:
request.Headers.Add("X-Authentication: " & ssoid)
request.AutomaticDecompression =
DecompressionMethods.GZip Or DecompressionMethods.Deflate
request.ServicePoint.Expect100Continue = False
request.Timeout = 2000
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
responseFromServer = reader.ReadToEnd()
'might need to change this as changed from form1
'frmDiagnostics.Print(responseFromServer)
reader.Dispose()
dataStream.Dispose()
response.Dispose()
'might need to change this as changed from form1
Catch ex As WebException 'Exception
frmDiagnostics.Print("SendSportsReq Error: " & ex.Message)
End Try
Return responseFromServer
End Function
----------
Thanks for any assistance
Cheers
Aidan
Am new to development for Betfair and am trying to create a list of horse racing UK races and runners with their Back and Lay prices displayed. I can get the course names and and runners etc...but am having an issue when trying to populate the prices...I keep getting error message "The remote server returned an error (400) Bad Request
I checked the URL and this seems to be correct -- https://api.betfair.com/exchange/betting/json-rpc/v1
Below is the code where I appear to be hitting the issue....any help would be greatly appreciated (I have removed my developer keys from the code below Request.Headers.Add
------------------------------------------
Private Function SendSportsReq(ByVal jsonString As String)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim request As HttpWebRequest =
WebRequest.Create _
("https://api.betfair.com/exchange/betting/json-rpc/v1")
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(jsonString)
Dim responseFromServer As String = ""
Try
request.Method = "POST"
request.ContentType = "application/json"
request.ContentLength = byteArray.Length
request.Headers.Add("X-Application:
request.Headers.Add("X-Authentication: " & ssoid)
request.AutomaticDecompression =
DecompressionMethods.GZip Or DecompressionMethods.Deflate
request.ServicePoint.Expect100Continue = False
request.Timeout = 2000
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
responseFromServer = reader.ReadToEnd()
'might need to change this as changed from form1
'frmDiagnostics.Print(responseFromServer)
reader.Dispose()
dataStream.Dispose()
response.Dispose()
'might need to change this as changed from form1
Catch ex As WebException 'Exception
frmDiagnostics.Print("SendSportsReq Error: " & ex.Message)
End Try
Return responseFromServer
End Function
----------
Thanks for any assistance
Cheers
Aidan



Comment