Google apps script &引用;无效参数";发送GET to spaces.members.list时
我正在尝试使用Apps脚本创建一个Google Hangouts聊天聊天机器人(在G套件中)。我想获得聊天室中所有人的列表,但这在应用程序脚本中还没有直接支持,所以我使用RESTAPI。API调用似乎很简单: 命令是Google apps script &引用;无效参数";发送GET to spaces.members.list时,google-apps-script,urlfetch,hangouts-chat,Google Apps Script,Urlfetch,Hangouts Chat,我正在尝试使用Apps脚本创建一个Google Hangouts聊天聊天机器人(在G套件中)。我想获得聊天室中所有人的列表,但这在应用程序脚本中还没有直接支持,所以我使用RESTAPI。API调用似乎很简单: 命令是 GEThttps://chat.googleapis.com/v1/{parent=spaces/*}/members 我已经为授权创建了一个服务帐户,然后使用 var endpoint = 'https://chat.googleapis.com/v1/{parent="spac
GEThttps://chat.googleapis.com/v1/{parent=spaces/*}/members
我已经为授权创建了一个服务帐户,然后使用
var endpoint = 'https://chat.googleapis.com/v1/{parent="spaces/pQkgxxxxxxx"}/members'
var options = {
method: "GET",
contentType : "application/json" ,
muteHttpExceptions : true,
headers: {
"Authorization": "Bearer " + goa.getToken(),
}
};
var response = UrlFetchApp.fetch(endpoint, options)`
我得到的
无效参数:{parent=“spaces/pQkgxxxxxxxx”}/members
我已尝试对
parent
参数进行编码,但错误仍然存在。有什么想法吗?根据您链接页面上的官方文档,路径参数父项的预期格式为空格/*
。给出的示例值为spaces/AAAAMpdlehY
换句话说,您不需要编写{parents=
和}
位,即使模板URL
获取https://chat.googleapis.com/v1/{parent=spaces/*}/members
有他们。此模板url格式在上有详细说明
在您的示例中,要获取的正确URI是https://chat.googleapis.com/v1/spaces/pQkgxxxxxxx/members
您还应该考虑,在响应中检查一个<代码> NEXPAGETCONKE/<代码>(并在下一个调用中传递URL参数<代码> pAutoKuts<代码> >时,需要多次调用来解析空间<代码> PQKGXXXXXX的所有成员。
你也应该考虑这个查询返回的成员可能包含成员资格的各种状态。虽然我不确定这是否是你的问题的直接解决方案,但是尝试<代码>空格/PQKGXXXXXX < /代码>而不是<代码> {Prime/PQKGXXXXXX(})}
likevar=https://chat.googleapis.com/v1/spaces/pQkgxxxxxxx/members“
?因为是必需的。要获取其成员列表的空间的资源名称,格式为“spaces/*”。示例:空格/AAAAMpdlehY
。