Problems with URL parameter
RaminMohazzab opened this issue · 6 comments
Hello! First of all: I am a physics teacher, so please don't expect too much from me. I want to query the contacts from the school's Office365. When I test the query in Microsoft Graphexplorer, everything works fine:
https://graph.microsoft.com/v1.0/users?$search="displayName:Mohazza"
but when I do the query with php, the options are ignored:
$str = 'users?$search="displayName:Mohazzab"'; <= No effect.
$response = $provider->get($str, $accessToken);
Can anybode help, please?
Thx
Ramin
Hey, no worries, all questions are welcome!
Can you please try calling Graph with full URL of the endpoint and see if that works?
$provider->get('https://graph.microsoft.com/v1.0/users?$search="displayName:Mohazzab"', $token);
/cc: @RaminMohazzab
Hey! Thank you for your answer. I tried this - i get this message:
Fatal error: Uncaught Error: Call to a member function hasExpired() on null in /var/www/web991/html/wordpress/elternsprechtag/vendor/thenetworg/oauth2-azure/src/Provider/Azure.php:204 Stack trace: #0 /var/www/web991/html/wordpress/elternsprechtag/vendor/thenetworg/oauth2-azure/src/Provider/Azure.php(169): TheNetworg\OAuth2\Client\Provider\Azure->request('get', 'https://graph.m...', NULL, Array) #1 /var/www/web991/html/wordpress/elternsprechtag/oauth.php(38): TheNetworg\OAuth2\Client\Provider\Azure->get('https://graph.m...', NULL) #2 {main} thrown in /var/www/web991/html/wordpress/elternsprechtag/vendor/thenetworg/oauth2-azure/src/Provider/Azure.php on line 204
Do i have to use another endpoint?
Thanks!
Hm, hasExpired
is being called on $token
, have you properly authenticated and obtained the token? I could do a quick Teams call to check it with you today (I am in GMT+1, Prague, Czech Republic timezone), so if we could get it aligned, would be probably quicker via a screen share. I am free between 15:00 - 16:30 today.
hey, this would be great! My Email: ramin.mohazzab@gympet.net
maybe it is a problem with the header - the key "ConsistencyLevel" is needed. Is this correct?
$headers = [
'ConsistencyLevel' => 'eventual',
];
$str = 'users?$search="displayName:Moh"';
$response = $provider->get($str, $accessToken, ['headers' => $headers]);
Yeah, consistency level is required as per docs: https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http