Hello,
I try to do my first request to list the:
"listMarketCatalogue"
for a Tennis game. For this test I have manually looked up the eventid in this URL which is a tennis game 2016-04-23
https://www.betfair.com/exchange/ten...nt?id=27769832
I beleive something with the JSON is wrong formatted. If it would be possible to find out how I put the information wrong in the string, then I possibly can understand how the format should look like for many other requests?
I get this error message when trying to send the request:
The remote server returned an error: (400) Bad Request.
//C# code
Thank you!
I try to do my first request to list the:
"listMarketCatalogue"
for a Tennis game. For this test I have manually looked up the eventid in this URL which is a tennis game 2016-04-23
https://www.betfair.com/exchange/ten...nt?id=27769832
I beleive something with the JSON is wrong formatted. If it would be possible to find out how I put the information wrong in the string, then I possibly can understand how the format should look like for many other requests?
I get this error message when trying to send the request:
The remote server returned an error: (400) Bad Request.
//C# code
Code:
String appkey = "appkey";
String sessiontoken = "sessiontoken ";
HttpWebRequest request = WebRequest.Create("https://api.betfair.com/exchange/betting/json-rpc/v1/") as HttpWebRequest;
request.Accept = "application/json";
request.Method = "POST";
request.KeepAlive = true;
request.ContentType = "application/json";
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
request.Headers.Add("Accept-Encoding", "gzip,deflate");
request.Headers.Add("X-Application", appkey); //App key
request.Headers.Add("X-Authentication", sessiontoken );
//Create the message and add it to the web request
string data = "{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listMarketCatalogue\", \"params\": " +
"{\"filter\":{" +
"\"eventTypeIds\": [\"2\"], " + //Tennis
"\"eventIds\": [\"27769832\"] " + //Tennis game id
"}," +
"{\"marketProjection\": " +
"[\"RUNNER_DESCRIPTION\",\"RUNNER_METADATA\"]" +
"}," +
"{\"maxResults\": " +
"\"20\"" +
"}}, \"id\": 1}";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(data);
streamWriter.Flush();
streamWriter.Close();
}
//The remote server returned an error: (400) Bad Request.
String responseBody = "";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
var stream = response.GetResponseStream();
responseBody = "";
using (var reader = new StreamReader(stream))
{
responseBody = reader.ReadToEnd();
reader.Close();
}
response.Close();
response.Dispose();
}
MessageBox.Show(responseBody);


Comment