# How to access a web API with HTTP POST and JSON

I want to get data using HTTPS from

POST https://developers.betfair.com/api.betfair.com/exchange/betting/json-rpc/v1 HTTP/1.1


using JSON

[{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEvents", "params": {"filter":{}}, "id": 1}]


I have to provide values for X-Application and X-Authentication ( which I have but are private for the account ).

I know that this can be done directly from Mathematica.

Which function should I use and where / how should I provide the URL, POST, X-Application, X-Authentication and JSON data.

Example code for a similar API would already be helpful, I guess.

• I generally use URLFetch with the "Headers" and "Body" option. – chuy Feb 8 '16 at 21:31
• @chuy - Ok. I did not know about all the options of URLFetch. Will look into that, I suppose that might work. – nilo de roock Feb 8 '16 at 21:52

This should do the trick if you fill in the appropriate authentication headers:

url = "https://developers.betfair.com/api.betfair.com/exchange/betting/json-rpc/v1";
json = "[{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listEvents\", \"params\":  {\"filter\":{}}, \"id\": 1}]";