I am trying the following sample code from the betfair api:
import requests
import json
url="https://api.betfair.com/betting/json-rpc"
header = { 'X-Application' : appKey, 'X-Authentication' : sessionToken, 'content-type' : 'application/json' }
jsonrpc_req='{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listCompetitions", "params": {"filter":{ "eventTypeIds" : [1] }}, "id": 1}'
print json.dumps(json.loads(jsonrpc_req), indent=3)
print " "
response = requests.post(url, data=jsonrpc_req, headers=header)
print json.dumps(json.loads(response.text), indent=3)
I keep getting ValueError: No JSON object could be decoded
.
Hazarding a guess here:
https://api.betfair.com/betting/json-rpc is returning a 404 when making a straight
GET
. You can see the result in the browser too. A good API returns the proper error code (401 or 403) if it's a header problem. Are you sure you're calling the correct endpoint?To troubleshoot, we'll need more info. What's the result of changing your last line to:
Looking at your update, you're seeing the same thing as me:
The requested resource (/betting/json-rpc) is not available.
Either you're sending the wrong header in your
POST
or, more likely, calling the wrong url. Doing a little digging, I think the correct one is:https://api.developer.betfair.com/betting/json-rpc