getAccountFunds returns error response

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thebettrader
    Junior Member
    • Apr 2016
    • 35

    #1

    getAccountFunds returns error response

    Hello,

    I am trying to do a call to "getAccountFunds" using the jsonrpc endpoint.
    I have looked at the documentation here:
    https://api.developer.betfair.com/se...etAccountFunds

    As I will return the UK wallet, I have not specified the wallet parameter and then created those JSON bodies as two attempts:

    Code:
                
    //Request body
    String data = "{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/getAccountFunds\", \"id\": 1}"; //First try
    String data = "{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/getAccountFunds\"}"; //Second try
    But both requests using either of those 2 bodies return this error response:
    Code:
    {"jsonrpc":"2.0","error":{"code":-32601,"message":"DSC-0021"},"id":1}
    I wonder if I am missing anything in the JSON there?

    Thank you!
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    The -32601 error means the method was not found.
    https://api.developer.betfair.com/se...ing+Exceptions

    I'm guessing that you used the same endpoint as you've been using for the bet-related calls. Let me know if this is a wrong guess!

    The end point for betting calls is this:
    "https://api.betfair.com/exchange/betting/json-rpc/v1/"

    The end point for account calls is this:
    "https://api.betfair.com/exchange/account/json-rpc/v1/"

    Comment

    • thebettrader
      Junior Member
      • Apr 2016
      • 35

      #3
      Originally posted by jabe View Post
      The -32601 error means the method was not found.
      https://api.developer.betfair.com/se...ing+Exceptions

      I'm guessing that you used the same endpoint as you've been using for the bet-related calls. Let me know if this is a wrong guess!

      The end point for betting calls is this:
      "https://api.betfair.com/exchange/betting/json-rpc/v1/"

      The end point for account calls is this:
      "https://api.betfair.com/exchange/account/json-rpc/v1/"

      That was good, I will keep that URL for checking error responses.

      Yes you are right, I did use the "betting" endpoint. I didn't know "account" has to be used there.
      However, I changed it to the "account" endpoint but I still receive the same error message, so I thought of posting the code I use and perheps anything can be find which is not correct in the call?

      Code:
                  String appkey = "aaaaaaaaa";
                  String sessiontoken = "bbbbbbbbb";
                  HttpWebRequest request = WebRequest.Create("https://api.betfair.com/exchange/account/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);
      
      
                  //data = "{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/getAccountFunds\", \"id\": 1}"; //First try
                  String data = "{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/getAccountFunds\"}"; //Second try
                     
      
                  using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                  {
                      streamWriter.Write(data);
                      streamWriter.Flush();
                      streamWriter.Close();
                  }
                  String responseBody = "";              
                  using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                  {
                      var stream = response.GetResponseStream();
                      using (var reader = new StreamReader(stream))
                      {
                          responseBody = reader.ReadToEnd();
                          reader.Close();
                      }
                      response.Close();
                      response.Dispose();
                  }

      Comment

      • jabe
        Senior Member
        • Dec 2014
        • 705

        #4
        Well, to my considerable surprise, my first attempt worked. I added a button, got it to pass the method name to my sendAccReq(ByVal method As String)
        routine, and it worked.

        It is, by the way, my program's first attempt to use the sendAccReq() routine. I found it somewhere months back. Sorry I can't credit the person who wrote it.

        My JSON string was this:

        {"jsonrpc": "2.0", "method": "AccountAPING/v1.0/getAccountFunds"}

        So it looks like you need to change your JSON data string like this:

        String data = "{\"jsonrpc\": \"2.0\", \"method\": \"AccountAPING/v1.0/getAccountFunds\"}"; //Second try

        So it's just AccountAPING/v1.0 instead of SportsAPING/v1.0. Sorry for not noticing that earlier - as I say, I've not used account calls before, so I never really looked at the code.



        I had changed my header compression to

        request.Headers.Add("Accept-Encoding", "gzip,deflate")

        instead of

        request.Headers.Add("Content-Encoding: gzip")

        but it didn't work, so I changed it back. If yours is working as you have it coded, that's great. No idea why mine didn't. I have a few lines in my sendAccReq() and sendBetReq() that are not the same as yours.
        Last edited by jabe; 24-04-2016, 02:24 AM.

        Comment

        • thebettrader
          Junior Member
          • Apr 2016
          • 35

          #5
          Originally posted by jabe View Post
          String data = "{\"jsonrpc\": \"2.0\", \"method\": \"AccountAPING/v1.0/getAccountFunds\"}"; //Second try

          So it's just AccountAPING/v1.0 instead of SportsAPING/v1.0. Sorry for not noticing that earlier - as I say, I've not used account calls before, so I never really looked at the code.


          I had changed my header compression to request.Headers.Add("Accept-Encoding", "gzip,deflate")

          instead of

          request.Headers.Add("Content-Encoding: gzip")

          but it didn't work, so I changed it back. If yours is working as you have it coded, that's great. No idea why mine didn't. I have a few lines in my sendAccReq() and sendBetReq() that are not the same as yours.

          That is great, the AccountAPING did the trick, thank you!
          When I changed to that it worked and it was possible to retreive the balance.
          I am not sure either about the compression and what the difference can be between the header you use and the one I use but in the request I do it works.

          Comment

          Working...
          X