msgraph-sdk-php
msgraph-sdk-php copied to clipboard
Bug on 412 Http status code
Hi, using the invitation endpoint on Microsoft Graph for a guest user that already exists on the directory I have an internal server error. The http status code returned from Graph Api is 412, that it seems not supported by the library.
Here the code I'm using:
` try {
$accessToken = $this->getAccessToken(['https://graph.microsoft.com/.default']);
$graph = new Graph();
$graph->setAccessToken($accessToken);
return $graph->createRequest("POST", "/invitations")
->addHeaders(array("Content-Type" => "application/json"))
->attachBody([
"invitedUserDisplayName" => "some values",
"invitedUserEmailAddress" =>"email",
"sendInvitationMessage" => false,
"inviteRedirectUrl" => "https://test.com"
])
->setReturnType(Model\Invitation::class)
->execute();
} catch (ClientException $e) {
if ($e->hasResponse()) {
dump(Psr7\str($e->getResponse()));
}
}
` EDIT: The bug occurs if the user already exists in the directory but his account was previously blocked.