Invalid_app_key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexb151
    Junior Member
    • Aug 2019
    • 3

    #1

    Invalid_app_key

    Hi
    When trying to access
    "https://api.betfair.com/exchange/betting/rest/v1.0/listEventTypes/"

    I'm getting the following response:
    {"faultcode":"Client","faultstring":"ANGX-0007","detail":{"APINGException":{"requestUUID":"i e2-ang23a-prd-08050849-0000544470","errorCode":"INVALID_APP_KEY","errorDe tails":""},"exceptionname":"APINGException"}}

    Im using exactly the same app key as I used to do the login request and that worked successfully.

    Any help would be much appreciated.

    Thanks,

    Alex
  • LiamP
    Junior Member
    • Oct 2015
    • 284

    #2
    Code used?

    Comment

    • alexb151
      Junior Member
      • Aug 2019
      • 3

      #3
      Originally posted by LiamP View Post
      Code used?
      Sorry wasn't sure what to post to start with. Below is login code then API request code

      Login code

      String urll = "https://identitysso.betfair.com/api/login";
      String post_params = "username=********&password=**********";
      byte[] postData = post_params.getBytes( StandardCharsets.UTF_8 );
      int postDataLength = postData.length;
      URL url = new URL( urll );

      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setConnectTimeout(1000*15);
      conn.setDoOutput(true);
      conn.setRequestMethod("POST");
      conn.setRequestProperty("Accept", "application/json");
      conn.setRequestProperty("X-Application", application_token);
      conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      conn.setRequestProperty("Content-Length", Integer.toString(postDataLength ));
      conn.setRequestProperty("User-Agent", "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52");
      conn.setRequestProperty("Connection", "Keep-Alive");

      try(DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {
      wr.write( postData );
      }

      int response_code = conn.getResponseCode();

      if (response_code == 200){

      BufferedReader livenminin = new BufferedReader(
      new InputStreamReader(
      conn.getInputStream()));

      StringBuilder livenminresponse = new StringBuilder();
      String livenmininputline;

      while ((livenmininputline = livenminin.readLine()) != null)
      livenminresponse.append(livenmininputline);

      String livenminresult = livenminresponse.toString();
      System.out.println(livenminresult);

      JSONObject obj = new JSONObject(livenminresult);
      String token = obj.getString("token");

      return token;




      API request code


      JSONObject post = new JSONObject("{"filter" : { }}");

      String urll = "https://api.betfair.com/exchange/betting/rest/v1.0/listEventTypes/";

      byte[] postData = post.toString().getBytes( StandardCharsets.UTF_8 );
      int postDataLength = postData.length;
      URL url = new URL( urll );

      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setConnectTimeout(1000*15);
      conn.setDoOutput(true);
      conn.setRequestMethod("POST");
      conn.setRequestProperty("X-Application", application_token);
      conn.setRequestProperty("X-Authentication", api_token);
      conn.setRequestProperty("Accept", "application/json");
      conn.setRequestProperty("Content-Type", "application/json");
      conn.setRequestProperty("Content-Length", Integer.toString(postDataLength ));

      try(DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {
      wr.write( postData );
      }

      int response_code = conn.getResponseCode();

      if (response_code == 200){

      BufferedReader livenminin = new BufferedReader(
      new InputStreamReader(
      conn.getInputStream()));

      StringBuilder livenminresponse = new StringBuilder();
      String livenmininputline;

      while ((livenmininputline = livenminin.readLine()) != null)
      livenminresponse.append(livenmininputline);

      String livenminresult = livenminresponse.toString();
      System.out.println(livenminresult);


      }
      else{System.out.println(response_code);

      BufferedReader livenminin = new BufferedReader(
      new InputStreamReader(
      conn.getErrorStream()));

      StringBuilder livenminresponse = new StringBuilder();
      String livenmininputline;

      while ((livenmininputline = livenminin.readLine()) != null)
      livenminresponse.append(livenmininputline);

      String livenminresult = livenminresponse.toString();
      System.out.println(livenminresult);

      }
      }
      catch (Exception e)
      {
      System.out.println(e);
      }

      Comment

      • alexb151
        Junior Member
        • Aug 2019
        • 3

        #4
        Fixed it, code was fine, was my stupid mistake. Had copied the live app key rather than delayed. And live wasn't activated.

        Comment

        • SergioDagest
          Banned
          • Aug 2019
          • 6

          #5
          That is a rather common issue. I have also faced such a situation several times and thanks to my friend who is a developer, this problem has been solved in a few minutes. He has told me that even professionals in their EffectiveSoft company who deals with very hard tasks like software for banks (https://www.effectivesoft.com/softwa..._industry.html) make such common and simple mistakes, that is ok, don't worry
          Last edited by SergioDagest; 14-08-2019, 08:27 AM.

          Comment

          Working...
          X