title: Assign a User to an Enterprise Application in Azure AD through Microsoft Graph API
body: <p>Through the PHP Graph SDK, I'm attempting to pragmatically assign a user to an Enterprise Application. However, I am getting the following error:</p>
  
  <pre><code>Unsupported segment type. ODataQuery: users/{user-id}...
  </code></pre>
  
  <p>Here is my function</p>
  
  <pre><code> public function assignUserToApp($user,$app)
  {
  $token = $this-&gt;getToken();
  $graph = new Graph();
  $graph-&gt;setAccessToken($token)
  -&gt;setApiVersion('beta');
  
  $newMemberRef = '/users/'.$user-&gt;getId().'/appRoleAssignments';
  $response = $graph-&gt;createRequest('PATCH', $newMemberRef)
          -&gt;attachBody([
              "principalId" =&gt; $user-&gt;getId(),
              "principalType" =&gt; "User",
              "resourceId" =&gt; $app,
              "creationTimestamp" =&gt; gmdate("Y-m-d\TH:i:s\Z")])
          -&gt;execute();
  }
  </code></pre>
  
  <p>I will greatly appreciate any form of  help.</p>