node.js - 无法在 Google Directory API 中获取根 Orgunit
问题描述
我正在尝试获取有关根组织单位的信息。我尝试使用orgunits.list和orgunits.get方法,但都失败了。
const service = google.admin({version: 'directory_v1', auth});
service.orgunits.list({
customerId: 'my_customer',
orgUnitPath: '/',
type: 'all'
}, (err, res) => {
if (err) return console.error('The API returned an error:', err.message);
const data = res.data;
console.log(data);
});
orgunits.list只返回两个值(如果我没有任何子单位):
{kind: "admin#directory#orgUnits", etag: "..."}
和orgunits.get返回未找到错误:
service.orgunits.get({
customerId: 'my_customer',
orgUnitPath: '/'
// orgUnitPath: 'id:...'
}, (err, res) => {
if (err) return console.error('The API returned an error:', err.message);
const data = res.data;
console.log(data);
});
只有当我添加一个子单位然后运行orgunits.list然后按照此处的建议在子单位中查找父单位 ID时,我才成功获取有关根组织单位的信息。
所以问题是如果没有子单元,如何获取根组织单元或组织单元 ID?
解决方案
我不确定您想要做什么,但在 Google 上获取根“/”组织单位会检索所有域。
推荐阅读
- html - 子元素的平滑悬停过渡
- mapbox - 用于 geojson 集合的 Mapbox 过滤,以根据值是否包含在特征有效 id 中进行过滤
- grep - 用 ^ 排除多个模式
- string - 如果字符串当前为空或为空,则尝试设置默认字符串属性值
- go - Cobra:在不使用包全局变量的情况下为子命令提供上下文?
- sharepoint - SharePoint 工作流 2010:在编辑一项时复制到整个列表列
- arrays - 填充 IList 接口中的多维数组错误
- git - 如果我忘记运行`git mv`,如何修复重命名的文件?
- bash - Make the if statement case insensitive in bash
- python - 我正在制作一个不和谐的机器人,当我在 cog 中执行此特定嵌入时,它会引发错误