newbie help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michael.dev
    Junior Member
    • Feb 2016
    • 1

    #1

    newbie help

    I am relatively new to programming and especially using APIs.

    I am trying to add Betfair odds to my website, but when trying to access the API via ajax I get this response

    XMLHttpRequest cannot load https://api.betfair.com/exchange/betting/json-rpc/v1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://podosfairaki.dev' is therefore not allowed access. The response had HTTP status code 400.

    btw the origin is a local dev address

    am I doing something wrong? do I have to wait for Betfair to approve my request to use Betfair API commercially? and if so, will i be able to get access to the app from my local origin?
  • JayBee
    Junior Member
    • Oct 2010
    • 114

    #2
    Do you have permission/license/whatever from Betfair to use their data on a public website?

    Copyright issues.

    Originally posted by michael.dev View Post
    I am relatively new to programming and especially using APIs.

    I am trying to add Betfair odds to my website, but when trying to access the API via ajax I get this response

    XMLHttpRequest cannot load https://api.betfair.com/exchange/betting/json-rpc/v1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://podosfairaki.dev' is therefore not allowed access. The response had HTTP status code 400.

    btw the origin is a local dev address

    am I doing something wrong? do I have to wait for Betfair to approve my request to use Betfair API commercially? and if so, will i be able to get access to the app from my local origin?

    Comment

    • johnny1333
      Junior Member
      • Apr 2016
      • 2

      #3
      same issue

      I have the same issue and its because CORS dont allow to fetch data from other origin and the api dont pass back the Access-Control-Allow-Origin header to the ajax request. Also asking befair devs if we somehow can call the api from the browser ajax?

      Comment

      • lorde
        Banned
        • Sep 2022
        • 1

        #4
        Originally posted by michael.dev View Post
        I am relatively new to programming and especially using APIs.

        I am trying to add Betfair odds to my website, but when trying to access the API via ajax I get this response

        XMLHttpRequest cannot load https://api.betfair.com/exchange/betting/json-rpc/v1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://podosfairaki.dev' is therefore not allowed access. The response had HTTP status code 400. nyt wordle

        btw the origin is a local dev address

        am I doing something wrong? do I have to wait for Betfair to approve my request to use Betfair API commercially? and if so, will i be able to get access to the app from my local origin?
        it's a copyright issue you don't have permission to view it

        Comment

        • pwebtech
          Member
          • Apr 2021
          • 49

          #5
          this is really just a browser security thing, if you really want to allow the cross origin request in your browser (not recommended), then something like this should work: https://stackoverflow.com/questions/...licy-in-chrome

          It's not really something betfair can address as adding a wildcard 'Access-Control-Allow-Origin' to the headers of the API end-point would make it possible for malicious scripts in web pages to potentially gain access to a user's betfair account via the cookies sent with xmlhttprequests/fetch calls

          simple solution is: get a server, backend, to call the betfair api and then call the server page from the client, i.e. don't call the betfair api directly from a browser

          Comment

          • jabe
            Senior Member
            • Dec 2014
            • 705

            #6
            I'm not sure of the value of replying to threads that are six years old. It's happened lately with what I can only describe as hit-and-run trolls. One "replied" recently to four threads that hadn't been touched for more than 6 years and the answers were not answers at all. That user posted all four on the same day and hasn't been back.

            Comment

            • pwebtech
              Member
              • Apr 2021
              • 49

              #7
              Agree, this one got past me, as it seemed almost a genuine (but wrong) reply/update, sorry!

              Comment

              • jabe
                Senior Member
                • Dec 2014
                • 705

                #8
                Originally posted by pwebtech View Post
                Agree, this one got past me, as it seemed almost a genuine (but wrong) reply/update, sorry!
                Nothing to worry about and no need at all to apologise. It's more about me and you wasting our time being helpful.

                Comment

                • kathy
                  Junior Member
                  • May 2023
                  • 1

                  #9
                  Originally posted by michael.dev View Post
                  I am relatively new to programming and especially using APIs.

                  I am trying to add Betfair odds to my website, but when trying to access the API via ajax I get this response

                  XMLHttpRequest cannot load https://api.betfair.com/exchange/betting/json-rpc/v1 melon playground​. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://podosfairaki.dev' is therefore not allowed access. The response had HTTP status code 400.

                  btw the origin is a local dev address

                  am I doing something wrong? do I have to wait for Betfair to approve my request to use Betfair API commercially? and if so, will i be able to get access to the app from my local origin?
                  In your case, it seems that the API endpoint you are trying to access does not allow cross-origin requests from your local domain, which is why you are receiving the error message.
                  You can try Enable CORS (Cross Origin Resource Sharing) on Betfair API server or Use a server side proxy

                  Comment

                  • adnantobitech
                    Junior Member
                    • Jul 2023
                    • 1

                    #10
                    so without setting a backend we cannot bypass CORS issue ? im trying to setup personal betting api in my react.js and im getting CORS issue. i have tried using proxy and CORS extentions but nothing seem to work for me.

                    Comment

                    Working...
                    X