I have a small script to pull information from a Trello API.
The script works fine when I've assigned the full URL to a String variable. However, when I pass the params separately, I get an error "unauthorized permission requested".
Working code:
var url = "https://api.trello.com/1/boards/57c68c1beaab4c676adfaeb1/lists?key=myTrelloKey&token=myTrelloToken";
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
Problematic code:
var url = "https://api.trello.com/1/boards/57c68c1beaab4c676adfaeb1/lists";
var options =
{
"key": "myTrelloKey",
"token": "myTrelloToken",
"muteHttpExceptions" : true
};
var response = UrlFetchApp.fetch(url,options);
Logger.log(response.getContentText());
I have tried to understand if it's an Authentication issue, but could not get my way around it. Am I doing something wrong in the second version? Thanks in advance!
I believe your current situation and goal as follows.
Working code:
works."key": "myTrelloKey"
and"token": "myTrelloToken"
as the query parameter.Modification points:
UrlFetchApp.fetch(url, params)
,params
has no properties ofkey
andtoken
.payload
, in that case, the request becomes POST method."key": "myTrelloKey"
and"token": "myTrelloToken"
as the query parameter, in the current stage, it is required to prepare a script.key
andtoken
can be directly used for the request body and the headers instead of the query parameter, unfortunately, these were not succeeded. It seems that these are used as the query parameters. RefWhen above points are reflected to your script, it becomes as follows.
Modified script:
References: