API request to quandl for fetching stock data returning HTML response instead of JSON. Its correctly returning JSON result in postman.
var url ='https://www.quandl.com/api/v3/datasets/BSE/BOM'+532540+'?start_date='+startDate+'&end_date='+endDate+'&collapse=weekly&api_key=myapikey'
console.log(url)
var options =
{
'muteHttpExceptions': true,
"contentType" : "application/json",
};
var response = UrlFetchApp.fetch(url, options);
console.log(response)
did anyone have a workaround?
Explicitly mention the format in the url as mentioned in the documentation
GET https://www.quandl.com/api/v3/datasets/{database_code}/{dataset_code}/data.{return_format}
var url ='https://www.quandl.com/api/v3/datasets/BSE/BOM'+532540+'.json?start_date='+startDate+'&end_date='+endDate+'&collapse=weekly&api_key=myapikey'
AND/OR
Accept
header. var options =
{
'muteHttpExceptions': true,
"contentType" : "application/json",
"headers":{"Accept":"application/json"}
};