I am working on a simple Google AppScript, where the public API works on postman, however it gives an error Unauthorized when I call it from Script. Can someone please help. Below is the code
I tried with and without Headers. With Headers it gives an error "Attribute provided with invalid value: Header:Host"
var url = 'https://www.moneycontrol.com/mc/widget/mfnavonetimeinvestment/get_chart_value?isin=INF846K01E25&dur=1W';
var headers = {
"Host": "www.moneycontrol.com",
"Content-Type": "application/json",
"Accept": "application/json"
};
var options = {
"method": "GET",
"contentType": "application/json",
"headers": headers,
};
try {
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
Logger.log(data);
}
catch (f) {
Logger.log(f.message);
}
where the public API works
Would you please provide a reference for documentation for the Moneycontrol.com "Public" API.