저는 매우 새롭고 해결하기 위해 최선을 다하고 있습니다. 누군가가 정말로 내 날을 구할 수 있다면 기쁠 것입니다.트리거를 사용하여 API를 호출하고 데이터를 가져 오려고 시도합니다.
트리거를 사용하여 API를 호출하고 Google 스크립트를 사용하여 데이터를 가져 오려고하면이 문제가 발생합니다.
기본적으로 우편 배달부에 putit을 넣으면 개체를 제공하는 API가 있습니다. 내가해야 할 일은 구글 스프레드 시트에서 그 객체들을 얻는 것 뿐이다.
필자에게 "가져 오기를 호출 할 수있는 권한이 없습니다."라는 오류를 표시하는 onOpen 함수를 시도했습니다.
따라서 첫 번째 열을 "데이터 가져 오기"로 편집하여 API를 호출 할 수 있습니다. 사전에
덕분에
function onEdit(e) {
var s = SpreadsheetApp.getActiveSheet();
if (s.getName() == "Sheet1") { //checks that we're on the correct sheet
var r = s.getActiveCell();
//Updates timestamp for lead entry and meetings.
var currentCellValue = r.getValue();
var user = Session.getEffectiveUser();
if (r.getColumn() == 1 && (currentCellValue == 'Get Data')) { //checks the column
var nextCell = r.offset(0, 4);
if (nextCell.getValue() == '') { //is empty?
nextCell.setValue(Utilities.formatDate(new Date(), "GMT+5:30", "dd/MM/yyyy HH:mm:ss")).setComment(user);
var url = "My API";
var headers = {
"Content-Type": "application/json",
"Authorization": "userkey"
};
var options = {"method":"GET","headers": headers
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response[0]);
}
}
}
}
작동하는 다른 문서를 확인하지 않았습니까? 그러나 편집하지 마라. 어쨌든 저에게 동일한 데이터를 얻을 수 있습니다. 아래 링크는 UrlFetch에서 데이터를 얻으려는 사람들에게 도움이 될 수 있습니다 .. https://gist.github.com/varun-raj/5350595a730a62ca1954 .. 감사합니다. Robin –