microsoft-graph php library problem with constructing valid query

Graham Jarvis 136 Reputation points
2021-08-06T15:02:41.203+00:00

I have created a shared drive called 'eicshare' on OneDrive. I am using the php library 'microsoft-graph'. I am connecting with an application token (not a user token, as the job will be run in the background on a server). I can retrieve group details, including the eicshare details, with the following snippet:
private function getGroups($accessToken)
{
try {
$graph = new Graph();
$graph->setAccessToken($accessToken);
$url = "/groups";
$groups = $graph->createRequest("GET", $url)
->execute();
} catch (\Exception $e) {
dd($e->getMessage());
}
return $groups->getBody();
}

However, I would like to retrieve the details (in particular the group id) for the specific group with the display name 'eicshare'. I tried adding search/filter clauses but keep running into errors. Please could you tell me how to restructure the above snippet to retrieve the eicshare drive details.
Also, if there is a good resource that I may refer to, please provide a link as I am having problems finding the correct resources to refer to.
Thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
{count} votes

Accepted answer
  1. Graham Jarvis 136 Reputation points
    2021-08-09T08:56:23.813+00:00

    Thanks for confirming @JosephXu-MSFT . Here is a snippet of how I resolved the problem:

          try {  
                $graph = new Graph();  
                $graph->setAccessToken($accessToken);  
                $url = '/groups?$count=true&$filter=startsWith(displayName, \''.$displayName.'\')';  
                $group = $graph->createRequest("GET", $url)  
                              ->execute();  
            } catch (\Exception $e) {  
                dd($e->getMessage());  
            }  
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful