I am trying to access API via google sheet apps script.
=====
function getFyToken(fyApiKey, fySecret) {
var fyUrl = "https://api.fyers.in/api/v2/generate-auth-token";
var fyOptions = {
'method': 'GET',
'headers': {
'Content-Type': 'application/json',
'Authorization': fyApiKey + ":" + fySecret
},
'muteHttpExceptions': true,
'payload': JSON.stringify({
"appId": fyApiKey
})
};
var fyResponse = UrlFetchApp.fetch(fyUrl, fyOptions);
var fyResponseCode = fyResponse.getResponseCode();
var fyResponseData = fyResponse.getContentText();
if (fyResponseCode == 200) {
var fyToken = JSON.parse(fyResponseData);
return fyToken["data"]["accessToken"];
} else {
Logger.log(fyResponseData);
throw new Error("Failed to login to Fyers API. Please check your API key and secret.");
}
}
=====
This function is throwing error
Info
{"s": "error", "code": 500, "message": "Invalid Request, please provide valid method"}
Would you please let me know what is going wrong and also let me know if any documentation I can refer to for Google App Scripts. Thanks.