I am attempting to communicate with the betfair API. My day job is as a C programmer working under windows and my programming skill set is extremely narrow. A lot of the documentation is a complete mystery to me. I have tried and failed to write C code for the betfair API. I failed at the first hurdle - i.e. I couldn't even login.
Plan B: it occurred to me that I could call curl from a DOS batch file. So I tried logging in by looking at these examples here:
https://raw.githubusercontent.com/be...ript_curl.bash
I guessed how to convert this bash script into DOS commands and came up with this:
curl -q -k --cert c:\openssl\bin\client-2048.crt --key c:\openssl\bin\client-2048.key https://identitysso.betfair.com/api/certlogin -d "username=dXHIDDENXro&password=XHIDDENX" -H "X-Application: curlCommandLineTest
Much to my amazement it worked and curl responded by outputting this:
{"sessionToken":"I4jp3mGRvtTi4uXHIDDENXNNlAHAZ7THe KPFubwc=","loginStatus":"SUCCESS"}
I'm assuming this session token be valid in this DOS box until I log out, or shut the DOS box. (correct me if I'm wrong)
So all well and good but then I tried to get list_all_event_types working. I tried the following:
set HOST=https://api.betfair.com/exchange/betting
set SESSION_TOKEN=I4jp3mGRvtTi4uXHIDDENXNNlAHAZ7THeKPF ubwc=
set APP_KEY=MakJHIDDEN8sbPIr
curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: %APP_KEY%" --header "X-Authentication: %SESSION_TOKEN%" --data "{\"filter\":{}}" %HOST%/rest/v1/listEventTypes/
Sadly there appeared to be no reply from curl. No error message, the command prompt ">" came back again, and that was the end of that.
Any ideas what I did wrong? Or how I can diagnose the problem?
Plan B: it occurred to me that I could call curl from a DOS batch file. So I tried logging in by looking at these examples here:
https://raw.githubusercontent.com/be...ript_curl.bash
I guessed how to convert this bash script into DOS commands and came up with this:
curl -q -k --cert c:\openssl\bin\client-2048.crt --key c:\openssl\bin\client-2048.key https://identitysso.betfair.com/api/certlogin -d "username=dXHIDDENXro&password=XHIDDENX" -H "X-Application: curlCommandLineTest
Much to my amazement it worked and curl responded by outputting this:
{"sessionToken":"I4jp3mGRvtTi4uXHIDDENXNNlAHAZ7THe KPFubwc=","loginStatus":"SUCCESS"}
I'm assuming this session token be valid in this DOS box until I log out, or shut the DOS box. (correct me if I'm wrong)
So all well and good but then I tried to get list_all_event_types working. I tried the following:
set HOST=https://api.betfair.com/exchange/betting
set SESSION_TOKEN=I4jp3mGRvtTi4uXHIDDENXNNlAHAZ7THeKPF ubwc=
set APP_KEY=MakJHIDDEN8sbPIr
curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: %APP_KEY%" --header "X-Authentication: %SESSION_TOKEN%" --data "{\"filter\":{}}" %HOST%/rest/v1/listEventTypes/
Sadly there appeared to be no reply from curl. No error message, the command prompt ">" came back again, and that was the end of that.
Any ideas what I did wrong? Or how I can diagnose the problem?


Comment