Access the Betfair Exchange API using Julia
I've been using Julia for about 2mths now, and have recently been trying to use Julia to access the Betfair API.
Note about this service are here.
https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Getting+Started
Whilst I can get the Python example working (& I have an appKey & sessionToken though not shown), I've not been able to successfully translate this Python into Julia.
In example below I get a StatusError 400 response (which is the closest I've gotten). Other attempts indicated Bound issues probably from the Python example using {} and ' which Ive attempted to then translate.
I've looked at other Stackflow questions, but found they don't have the complexity associated with this example.
Wondering if anyone has any thoughts.
Thanks in advance
using HTTP
url="https://api.betfair.com/exchange/betting/json-rpc/v1"
header = ""X-Application" : "appKey", "X-Authentication" : "sessionToken" ,"content-type" : "application/json" "
jsonrpc_req=""jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {"filter":{ }}, "id": 1"
response = HTTP.post(url, data=[jsonrpc_req], headers=[header])
println(response.text)
Expected Results.
In Python, I get a summary of Betfair Sports and Market's.
{"jsonrpc":"2.0","result":[{"eventType":{"id":"1","name":"Soccer"},"marketCount":10668},{"eventType":{"id":"2","name":"Tennis"},"marketCount":4590},{"eventType":{"id":"3","name":"Golf"},"marketCount":43},{"eventType":{"id":"4","name":"Cricket"},"marketCount":394},{"eventType":{"id":"5","name":"Rugby Union"},"marketCount":37},{"eventType":{"id":"1477","name":"Rugby League"},"marketCount":24},{"eventType":{"id":"6","name":"Boxing"},"marketCount":27},{"eventType"
...etc...
Currently get
HTTP.ExceptionRequest.StatusError(400, HTTP.Messages.Response:
400 Bad Request.
question from:
https://stackoverflow.com/questions/65875303/how-to-use-rest-api-in-julia