通过Microsoft Graph API将用户分配到Azure AD中的企业应用程序

时间:2018-03-10 14:01:55

标签: microsoft-graph

通过PHP Graph SDK,我试图将用户实际分配给企业应用程序。但是,我收到以下错误:

Unsupported segment type. ODataQuery: users/{user-id}...

这是我的功能

 public function assignUserToApp($user,$app)
{
$token = $this->getToken();
$graph = new Graph();
$graph->setAccessToken($token)
->setApiVersion('beta');

$newMemberRef = '/users/'.$user->getId().'/appRoleAssignments';
$response = $graph->createRequest('PATCH', $newMemberRef)
        ->attachBody([
            "principalId" => $user->getId(),
            "principalType" => "User",
            "resourceId" => $app,
            "creationTimestamp" => gmdate("Y-m-d\TH:i:s\Z")])
        ->execute();
}

我将非常感谢任何形式的帮助。

1 个答案:

答案 0 :(得分:0)

updating /appRoleAssignments的原型是:

PATCH /users/{userId}/appRoleAssignments/{appRoleId}

您错过了请求中的/{appRoleId}