markitondemand / DEPRECATED-DataApis

Markit On Demand - Market Data APIs
http://dev.markitondemand.com
MIT License
178 stars 68 forks source link

Quote API returning Document Moved HTML instead of JSON response #48

Closed renu1999 closed 7 years ago

renu1999 commented 7 years ago

Quote API returning HTML instead of JSON response . However the API works fine when accessed in the browser directly or using curl command

I am using nodejs to make http request to http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=AAPL

getting response below

Document Moved

Object Moved

This document may be found here Document Moved

Object Moved

This document may be found here

undefined:1

Document Moved

^

Appreciate your help with this issue.

brianbaker commented 7 years ago

Can you share a code snippet? I made a quick test and receive a 200 status code along with the JSON response.

const http = require('http');

http.get('http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=AAPL', (res) => {
    console.log(res.statusCode);

    var data = '';
    res.on('data', (chunk) => data += chunk);
    res.on('end', () => {
        console.log(data);
    });
});
λ node http.js
200
{"Status":"SUCCESS","Name":"Apple Inc","Symbol":"AAPL","LastPrice":121.94,"Change":0.0600000000000023,"ChangePercent":0.0492287495897623,"Timestamp":"Thu Jan 26 00:00:00 UTC-05:00 2017","MSDate":42761,"MarketCap":641138083040,"Volume":26337576,"ChangeYTD":115.82,"ChangePercentYTD":5.28406147470213,"High":122.44,"Low":121.6,"Open":121.67}
renu1999 commented 7 years ago

Thanks for your quick reply & your help!

Looks like the my code is using http://dev.markitondemand.com/Api/v2/Quote/json?symbol=AAPL

and not http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=AAPL

the app is not handling the redirection as a result seeing a document move message.

I update my code to use /MODApis/* URIs and it works.

Have a nice weekend !

-Renuka


From: Brian Baker notifications@github.com Sent: Friday, January 27, 2017 10:09 AM To: markitondemand/DataApis Cc: renu1999; Author Subject: Re: [markitondemand/DataApis] Quote API returning Document Moved HTML instead of JSON response (#48)

Can you share a code snippet? I made a quick test and receive a 200 status code along with the JSON response.

const http = require('http');

http.get('http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=AAPL', (res) => { console.log(res.statusCode);

    var data = '';
    res.on('data', (chunk) => data += chunk);
    res.on('end', () => {
            console.log(data);
    });

});

? node http.js 200 {"Status":"SUCCESS","Name":"Apple Inc","Symbol":"AAPL","LastPrice":121.94,"Change":0.0600000000000023,"ChangePercent":0.0492287495897623,"Timestamp":"Thu Jan 26 00:00:00 UTC-05:00 2017","MSDate":42761,"MarketCap":641138083040,"Volume":26337576,"ChangeYTD":115.82,"ChangePercentYTD":5.28406147470213,"High":122.44,"Low":121.6,"Open":121.67}

- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/markitondemand/DataApis/issues/48#issuecomment-275687208, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AORGQspDFynYvRXQhXF6X8MkHc1vKI4iks5rWgi6gaJpZM4LvUXj.