組織に外部ユーザーを追加するには、ユーザーを直接作成する代わりに招待状RESTを使用する必要があります。ここにあなたの参照のためのRESTとコードサンプル(マイクロソフトグラフSDK)は、次のとおりです。
POST https://graph.microsoft.com/v1.0/invitations
Content-type: application/json
Content-length: 551
{
"invitedUserEmailAddress": "[email protected]",
"inviteRedirectUrl": "https://myapp.com"
}
コードサンプル:
string accessToken = "";
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
return Task.FromResult(0);
}));
Invitation invitation = new Invitation();
invitation.SendInvitationMessage = true;
invitation.InvitedUserEmailAddress = "[email protected]";
invitation.InviteRedirectUrl = "http://localhost";
var result= graphserviceClient.Invitations.Request().AddAsync(invitation).Result;
上に行くためにここに十分ではありません。どのように認証していますか?どのSDKを使用していますか?あなたは 'userPrincipalName'のために何を使いましたか? –