1

I am trying to get data from Quandl (https://www.quandl.com/data/YAHOO/MSFT.json) web site. It works perfectly well with all browsers and other REST clients like Postman.

My angular $http call looks quite simple and I've tried quite a few combinations with or without header.

$http({
        url: 'https://www.quandl.com/data/YAHOO/MSFT.json',
        method: "GET",
        headers: {
            "X-Content-Type-Options": "nosniff",
            "X-Frame-Options": "SAMEORIGIN",
            "X-Rack-CORS": "preflight-hit; no-origin"
        }
    })
    .then(res => {
        console.log(res);
    });

getting a standard error

XMLHttpRequest cannot load https://www.quandl.com/data/YAHOO/MSFT.json. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:2992' is therefore not allowed access. The response had HTTP status code 405.

However, vendor seems to support CORS http://help.quandl.com/article/280-does-the-quandl-api-support-cross-origin-resource-sharing-cors

Any ideas?

Thanks

user1153896
  • 293
  • 7
  • 17

2 Answers2

1

Quandl supports CORS when requesting data through the API. The URL you are trying to use is for the web page of the dataset. To make an API call instead, all that you have to do is find the Quandl code for that dataset and pass it to the API.

You can find the Quandl code at the top right of that page (YAHOO/MSFT in this case). So, the appropriate API call for your request would be https://www.quandl.com/api/v3/datasets/YAHOO/MSFT.json.

You can see full documentation for working with the Quandl API here: https://www.quandl.com/docs/api.

Jason Byck
  • 11
  • 1
  • 2
0

Have you checked if you are using the correct URL? Quandl proposes a different URL for its API. See Quandl - How do I download a dataset using the API

Your URL should be: https://www.quandl.com/api/v3/datasets/YAHOO/MSFT-MSFT-Microsoft-Corporation.json

Alexander
  • 1,356
  • 9
  • 16