Share via

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 Security | Microsoft Graph

Answer accepted by question author

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());  
        }  

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.