【问题标题】:Google Apps ProvisioningGoogle Apps 配置
【发布时间】:2015-05-05 09:26:58
【问题描述】:

我正在尝试通过独立的 C# 代码使用 Admin SDK API 向 Google 提供用户。

到目前为止,我可以在 Google 中搜索、创建和更新用户,但是我可以推送到 Google 的属性非常基本,例如名字、姓氏、主要电子邮件、密码或组织 ID,但是当我在尝试传递电话或电子邮件等属性,然后我没有收到任何错误,但它没有反映在 Google 中。

在我用来更新用户电话号码或电子邮件的 sn-p 下方(如果我更新用户名或任何字符串属性,相同的 sn-p 工作正常)。

            User user = dirservice.Users.Get("anurag.tripathi@mydomain.com").Execute();
            User newuserbody = new User();

            UserEmail emails = new UserEmail();
            emails.Address = "er.anuragtripathi@mydomain.com";
            emails.Primary = true;
            emails.Type = "personal";

            UserPhone phone = new UserPhone();
            phone.Type = "work";
            phone.Value = "426275674";
            newuserbody.Phones = phone;
            newuserbody.Emails = emails;

            User update = dirservice.Users.Update(newuserbody,user.PrimaryEmail).Execute();

            Console.WriteLine("Post Update"+update.Phones);

请建议正确的方法来更新组织、电话或电子邮件地址等属性。

【问题讨论】:

  • 在代码中,电话应该是数组的一部分,请查看此链接developers.google.com/admin-sdk/directory/v1/reference/users/…phones[].value,phones[].type。换手机后应该就可以更新了。
  • 您好,SGC,感谢您的回复。我已将电话属性更改为数组,但是它给出了错误(对象引用未设置为对象的实例)。我正在使用以下语法来更新电话号码。用户电话[] 电话=新用户电话[2];电话[0].Type=“工作”;电话[0].值“426275674”; newuserbody.Phones=phones 用户更新 = dirservice.Users.Update(newuserbody,user.PrimaryEmail).Execut();

标签: .net google-apps google-admin-sdk


【解决方案1】:

您需要 JSON 数组。对于组织和电话,使用由 JToken 条目组成的 Newtonsoft.Json.Linq.JArray。然后你可以使用

设置你的手机值
newuserbody.Phones = (JArray)phonearray;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-12
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    相关资源
    最近更新 更多