Empty response to any SportsAPING operation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rotteborp
    Junior Member
    • Feb 2009
    • 2

    #1

    Empty response to any SportsAPING operation

    Hello everyone.

    Does anyone experienced such a problem?
    I am able to login with my appKey and SSL certificate.. Able to getFunds successfully, getting actual balance.
    But when I am trying any sportsAPI operation, i get this in return:
    Code:
    [{"jsonrpc":"2.0","result":[],"id":1}]
    I tried to use example file from github repository, with the same issue. sending this:
    Code:
    [{"jsonrpc":"2.0","method":"SportsAPING/v1.0/listEventTypes","params":{"filter":{}},"id":1}]
    to
    https://api.betfair.com/exchange/betting/json-rpc/v1

    and getting this in response:
    Code:
    [{"jsonrpc":"2.0","result":[],"id":1}]
    i was able to locate this topic in the net, with the same issue:
    https://forum.developer.betfair.com/...mpty-responses
    so i made one bet and it is already settled. I have 12.5 USD on my account now, and one bet that was just settled not a long ago.

    but this gave no effect so far. Maybe there're other API restrictions i do not know about?
    Thanks a lot for help!

    Regards
  • Rotteborp
    Junior Member
    • Feb 2009
    • 2

    #2
    p.s. update: i am able to retrieve data successfully using demo tools and my keys
    https://docs.developer.betfair.com/v...ts-operations/

    but scripts does not work at all, including PHP sample script jsonrpc.php i took from here:
    https://github.com/betfair/API-NG-sa...ree/master/php

    does country location matter? my server is in germany, but i use Zurich proxy just in case. in both case i am able to login successfully via API and get sessionKey. And in both case i cannot get listEventTypes, no matter use I proxy or not
    Last edited by Rotteborp; 03-08-2021, 02:19 PM.

    Comment

    • jabe
      Senior Member
      • Dec 2014
      • 705

      #3
      In the API documentation it specifies which parameters are mandatory. With ListEventTypes, you have to specify the MarketFilter parameter, so that explains the lack of data retrieved on that call.

      Country or territory location can be important. There should be an explanation of this somewhere.

      If you have other failing calls, feel free to post those calls and I'll see if I can work out why they fail.

      Comment

      • Dunky
        Junior Member
        • Sep 2022
        • 14

        #4
        I'm having this issue.

        There's this example in the Getting Started section:
        jsonrpc_req='{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {"filter":{ }}, "id": 1}'​

        Where's the filter there?

        Comment

        • BetfairDeveloperProgram
          Administrator
          • Oct 2008
          • 680

          #5
          Hi Dunky,

          The example in the Getting Started guide shows an empty filter as this guarantees that all possible event types will be returned in the listEventTypes response.

          An example of a request that contains a filter is

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


          Kind Regards

          Neil

          Comment

          • Dunky
            Junior Member
            • Sep 2022
            • 14

            #6
            Thanks Neil. I don't actually want any filters. I'm having trouble with this code (borrowed code from the VBA example -I'm sure it worked 2 years ago!)...

            Function SendRequest(URL, AppKey, Session, Data) As String
            On Error GoTo ErrorHandler:
            Dim xhr: Set xhr = CreateObject("MSXML2.XMLHTTP")

            With xhr
            .Open "POST", URL & "/", False
            .setRequestHeader "X-Application", AppKey
            .setRequestHeader "Content-Type", "application/json"
            .setRequestHeader "Accept", "application/json"
            End With

            If Session <> "" Then
            xhr.setRequestHeader "X-Authentication", Session
            End If

            xhr.send Data
            SendRequest = xhr.ResponseText

            If xhr.status <> 200 Then
            Err.Raise vbObjectError + 1000, "Util.SendRequest", "The call to API-NG was unsuccessful. Status code: " & xhr.status & " " & xhr.statusText & ". Response was: " & xhr.ResponseText
            End If

            Set xhr = Nothing
            Exit Function

            ErrorHandler:
            Call HandleError(URL)
            End Function

            Comment

            • Dunky
              Junior Member
              • Sep 2022
              • 14

              #7
              listEventsTypes failed: JSON error code:

              Comment

              • Dunky
                Junior Member
                • Sep 2022
                • 14

                #8
                URL: "https://api.betfair.com/exchange/betting/json-rpc/v1"
                Data: "{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {"filter":{}}, "id": 1}"

                Comment

                • Dunky
                  Junior Member
                  • Sep 2022
                  • 14

                  #9
                  Seeing in other code now there's a WebRequest object instead of that MSXML2.XMLHTTP thing. Why do they have multiple ways of doing things, to confuse me?

                  Comment

                  • jabe
                    Senior Member
                    • Dec 2014
                    • 705

                    #10
                    Originally posted by Dunky View Post
                    URL: "https://api.betfair.com/exchange/betting/json-rpc/v1"
                    Data: "{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {"filter":{}}, "id": 1}"
                    These are the same as mine and are good.

                    Comment

                    • jabe
                      Senior Member
                      • Dec 2014
                      • 705

                      #11
                      This is the beginning of a common routine I used to send most of the JSON code. Uses the WebRequest object, so might help you along. VB rather than VBA,

                      Haven't included the rest of the routine as it's rather a mess of comments about unhandled conditions, but could tidy it up and post it if necessary.

                      Can't find/remember how to wrap it in code tags.



                      Public Function API_sendBetReq(ByVal method As String, ByVal params As String)

                      Dim request As WebRequest = WebRequest.Create("https://api.betfair.com/exchange/betting/json-rpc/v1/")

                      Dim postData As String = "{""jsonrpc"": ""2.0"", ""method"": ""SportsAPING/v1.0/" & method & """, ""params"": {" & params & "},""id"": 1}"
                      Dim JSONByteData As Byte() = Encoding.UTF8.GetBytes(postData)
                      ' MessageBox.Show(postData)
                      request.Method = "POST"
                      request.ContentType = "application/json-rpc"
                      request.ContentLength = JSONByteData.Length ' added this later to fix an issue
                      request.Headers.Add("X-Application: " & appKey)
                      request.Headers.Add("X-Authentication: " & ssoid)
                      request.Headers.Add("Content-Encoding: gzip") ' THIS WORKED​

                      Comment

                      • Dunky
                        Junior Member
                        • Sep 2022
                        • 14

                        #12
                        Thanks jabe, I will look into WebRequest.

                        My SendRequest Function works fine for the login bit but not for the ListEventTypes.

                        So...
                        URL: https://identitysso.betfair.com/api/keepAlive
                        Data: {"jsonrpc": "2.0", "method": "SportsAPING/v1.0/https://identitysso.betfair.com/api/keepAlive", "params": , "id": 1}
                        works (same AppKey & Session of course) while...
                        URL: https://api.betfair.com/exchange/betting/json-rpc/v1
                        Data: {"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {"filter":{}}, "id": 1}
                        does not.

                        Comment

                        • Dunky
                          Junior Member
                          • Sep 2022
                          • 14

                          #13
                          OK, solved my little problem. Forgot that you needed to update the session key on the interactive login. Oof!

                          Comment

                          • jabe
                            Senior Member
                            • Dec 2014
                            • 705

                            #14
                            Good stuff. A point that you might find of interest - I had trouble with the Keep Live request, but, despite adding code to make the call, I found it wasn't required. When I ran and stopped my program, it happily used the same session code for the rest of the day. Things might have changed by now, however, and there are still bits of code I need to write.
                            Last edited by jabe; 08-08-2024, 08:30 PM.

                            Comment

                            • Dunky
                              Junior Member
                              • Sep 2022
                              • 14

                              #15
                              The token supposedly lasts 24hrs for UK & Ireland users, although I seem to remember it disconnecting on me a time or two when I tried without it. Not sure if there's any triggers that can cause a disconnect.

                              Comment

                              Working...
                              X