在Google管理员控制台中的
Building id
在我的代码中:
var newUser = new User()
{
// ...
};
// ...
newUser.Locations = new List<UserLocation>()
{
new()
{
BuildingId = command.BuildingId,
}
};
// ...
var request = _service.Users.Insert(newUser);
var user = await request.ExecuteAsync();
最后一行投掷
Google.GoogleApiException
服务管理员抛出了例外。 httpstatuscode是badrequest。必需参数:[resource.location.field [0] .value]
TL; DR:设置区域和类型为
desk
newUser.Locations = new List<UserLocation>()
{
new()
{
Area = "desk",
BuildingId = command.BuildingId,
Type = "desk",
}
};
Area
对于要在GUI中显示的构建ID,也必须设置newUser.Locations = new List<UserLocation>()
{
new()
{
Area = "desk",
BuildingId = command.BuildingId,
}
};
。基于GUI集合
Type
和Type
在设置时,看起来两个属性都需要将两个属性设置为Area
。在下面的更改中,建筑物ID现在在GUI中显示在
Building id
方法论I通过在GUI中设置
desk
,然后通过API使用户发现了这一点。
不幸的是,在.NET Google Admin SDK中,是类型的。在运行时,您可以看到它是一个纽顿(Newtonsoft)数组。我写了一个专门用于公共领域的扩展课:newUser.Locations = new List<UserLocation>()
{
new()
{
Area = "desk",
BuildingId = command.BuildingId,
Type = "desk",
}
};