Nuget Microsoft Graphを使用してこのメソッド非同期を使用してグループを作成すると、信じられている同じ瞬間にこのグループにユーザーを追加することができます。Microsoft Graphを使用してプログラムでOffice 365の連絡先のグループにユーザーを追加するにはどうすればよいですか?私のコードは、メンバーなしでグループを作成しただけです
私はそれを試してみましたが、あなたのコンテンツの "Group"クラス、 "Owners"、 "Members"、 "MemberOf"はインターフェースです。
私はそれを試してみました。それは動作しません。
これは私の証拠の1つです。 ユーザーjona = graphClient.Me.Request()を待機しています。GetAsync(); //このコード行は、ログに記録されたユーザーのすべての情報を返します。 group.Owners.add(jona); //この行が条件 "if"の前にある場合
例外 "SystemNullException"が表示されます。
public async Task<List<ResultsItem>> CreateGroup(GraphServiceClient graphClient)
{
List<ResultsItem> items = new List<ResultsItem>();
string guid = Guid.NewGuid().ToString();
Group group = await graphClient.Groups.Request().AddAsync(new Group
{
GroupTypes = new List<string> { "Unified" },
DisplayName = Resource.Group + guid.Substring(0, 8),
Description = Resource.Group + guid,
MailNickname = Resource.Group.ToLower() + guid.Substring(0, 8),
MailEnabled = false,
SecurityEnabled = false
});
if (group != null)
{
// Get group properties.
items.Add(new ResultsItem
{
Display = group.DisplayName,
Id = group.Id,
Properties = new Dictionary<string, object>
{
{ Resource.Prop_Description, group.Description },
{ Resource.Prop_Email, group.Mail },
{ Resource.Prop_Created, group.AdditionalData["createdDateTime"] }, // Temporary solution for a known SDK problem.
{ Resource.Prop_Id, group.Id }
}
});
}
return items;
}
この質問に対する答えを見つけようとしていましたが、graphClient.Groups ["groupObjectID"]。Members.Request()。GetAsync()はAddメソッドを持つ有望なインターフェイス型オブジェクトを返します。 ..それ以上は関係ありません。それの目的は何か? – ZorgoZ
あなたの要件は何ですか?あなたはグループのメンバーになりたいですか?はいの場合は、私の返信[ここ](https://stackoverflow.com/a/44172196/5751404)を参照してください。 –
あなたは間違っています。実際の効果がない場合、なぜAddメソッドがあるのだろうかと思っていました。 – ZorgoZ