【问题标题】:Problems with Directory API: Custom User Schema目录 API 的问题:自定义用户架构
【发布时间】:2015-11-13 16:03:35
【问题描述】:

我正在编写一个函数来更新用户的信息。我做到了,它工作正常,但是当我想使用自定义模式时它不起作用。我检查了reference,但它显示错误 "Invalid Input: [employmentData] "

function directoryUpdate(userId, userDept, userLocation, userPhone,userTitle) {

var userId = 'devtest@pruebatest.com',userDept='D003', userLocation='L003';
var userTitle='T003';

var update = {

ims: 
[{
type: "work",
protocol: "gtalk",
im: "liz_im@talk.example.com",
primary: true
}],
emails: [
 {
 address: "liz@example.com",
 type: "home",
 customType: "",
 primary: true
 }
 ],


addresses: 
  [{
     type: "home",
     customType: "",
     streetAddress: "1600 Amphitheatre Parkway",
     locality: "Mountain View",
     region: "CA",
     postalCode: "94043" 
 }
  ],
organizations: 
  [{
    name: "Next Step",
    title: userTitle,
    primary: true,
    type: "work",
    department: userDept,
    location: userLocation
  }],

  customSchemas: {
  employmentData: {
   employeeNumber: "123456789",
   jobFamily: "Engineering",
   location: "Atlanta",
   jobLevel: 8,
   projects: [
    { value: "GeneGnome", customType: "development" },
    { value: "Panopticon", customType: "support" }
   ]
  }
 }

};
update = AdminDirectory.Users.patch(update, userId);
Logger.log('User %s updated with result %s.', userId, update)
return true;
}

什么是错误?

您好,提前致谢。

【问题讨论】:

  • 我尝试了相同的基本字段,如姓名、ID 等......但它也不起作用。

标签: google-apps-script google-directory-api google-admin-sdk


【解决方案1】:

employmentData 字段位于“customSchemas”字段中。在使用它们之前必须定义自定义模式。 要创建自定义架构,您必须使用资源 Schemas.insert。

使用对应字段和值类型(STRING、INT、ETC)创建架构后,您的代码应该可以正常运行。我试过了,对我有用。

另外,更新用户后,在调用 Users.get 时,您必须设置参数“projection=full”才能在响应中看到这些值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-04
    • 1970-01-01
    相关资源
    最近更新 更多