Постановка проблемы: Невозможно получить данные, используя clubhouse.io api в листах Google> Редактор сценариев
Per developers.google. com : Некоторые методы HTTP (например, GET) не принимают полезную нагрузку. Однако ожидаемый объем / полезная нагрузка API v3 clubhouse в запросе GET
Здесь Метод:
function getClubhouseStories() {
try{
var myHeaders = {"Content-Type": "application/json"};
var requestOptions = {
method: 'GET',
headers: myHeaders,
body: JSON.stringify({"query":"lable\:my label"}),
redirect: 'follow',
query: {"token": "XXXXXXXXUUIDXXXXX"},
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch("https://api.clubhouse.io/api/v3/search/stories", requestOptions);
}
catch(error) {
console.error(error);
}
var responseCode = response.getResponseCode();
var responseContent = response.getContentText();
Logger.log(responseCode);
Logger.log(responseContent);
}
Возвращает:
responseCode >> 401
responseContent >> "{"message":"Sorry, the organization context for this request is missing. If you have any questions please contact us at support@clubhouse.io.","tag":"organization2_missing"}"
Тот же самый запрос прекрасно работает через postman
или bash
, и запросы, которые не нуждаются в теле также работают через UrlFetchApp.fetch
Метки:
#clubhouse-api #google-apps-scripts #postman