0
votes

Hello Everyone,

I am trying to fetch all the office 365 groups using MS Graph API by using PHP Curl.

Below is my code as,
$ch = curl_init('https://graph.microsoft.com/v1.0/groups');
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array('Authorization: Bearer '.$accessToken, 'Content-Type: application/json;'),
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_VERBOSE => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => json_encode(array('securityEnabledOnly'=>true))
));
$out = curl_exec($ch);
curl_close($ch); print_r($out);

OUTPUT:
{
"error": {
"code": "Request_BadRequest",
"message": "A value is required for property 'displayName' of resource 'Group'.",
"innerError": {
"request-id": "0961dd91-37ec-48d6-99bc-47f9e4b1d989",
"date": "2018-03-08T08:31:09"
}}}

I am using the same access token for fetching details by other MS Graph API's which are working fine but in this case, I get this error. Also, my tenant is approved for all users via admin consent.

Please help me in this as now I've no clue how to proceed.

1

1 Answers

0
votes

The root of my issue (calling List Users) was that I was using POST and not GET, I see in the documentation that List Groups is supposed to be a GET as well. Using POST results in "A value is required for property '_______' of resource"