使用UrlFetchApp.fetch无法检索clubhouse.io api

问题描述 投票:1回答:1

问题陈述:无法使用clubhouse.io api检索数据在Google表格中>脚本编辑器

每个developers.google.com 某些HTTP方法(例如GET)不接受有效负载。但是,clubhouse v3 api期望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 [email protected].","tag":"organization2_missing"}"

相同的请求通过postmanbash可以完美工作,不需要正文的请求也可以通过UrlFetchApp.fetch进行工作>

标签:

#clubhouse-api #google-apps-scripts #postman

问题陈述:无法使用Google表格中的clubhouse.io api检索数据>脚本编辑器每个developers.google.com:某些HTTP方法(例如GET)不接受有效载荷。 ...

bash google-apps-script postman urlfetch
1个回答
0
投票

您可以将tokenquery参数作为URL的一部分。

© www.soinside.com 2019 - 2024. All rights reserved.