I'm trying to call getAccountFunds from the accounts API using a JSON request, I keep getting the error "NO_SESSION" though. My app key and session token are ok as the rest of my program is working fine, so there must be something wrong with the request, cant figure out what though:
Code:
Private Function SendRequest(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String) As String
Dim req As WebRequest = WebRequest.Create(uri)
req.ContentType = contentType
req.Method = method
req.ContentLength = jsonDataBytes.Length
Dim stream = req.GetRequestStream()
stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
stream.Close()
Dim response = req.GetResponse().GetResponseStream()
Dim reader As New StreamReader(response)
Dim res = reader.ReadToEnd()
reader.Close()
response.Close()
Return res
End Function
Private Sub Get_Funds()
Dim endpoint As New Uri("https://api.betfair.com/exchange/account/json-rpc/v1/getAccountFunds/")
Dim header As String = "{ 'X-Application' : '" & appkey & "', 'X-Authentication' : '" & sessionToken & "' ,'content-type' : 'application/json' }"
Dim json_req As String = "{""jsonrpc"":""2.0"",""method"":""AccountAPING/v1.0/getAccountFunds"",""id"":""1"",""params"":{""locale"":""en""} }"
Dim data = Encoding.UTF8.GetBytes(json_req)
Dim result_post = SendRequest(endpoint, data, header, "POST")
PrintOut(result_post.ToString)
End Sub


Comment