Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with URL parameter #137

Open
RaminMohazzab opened this issue Feb 15, 2021 · 6 comments
Open

Problems with URL parameter #137

RaminMohazzab opened this issue Feb 15, 2021 · 6 comments
Labels

Comments

@RaminMohazzab
Copy link

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

@hajekj
Copy link
Member

hajekj commented Feb 16, 2021

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

@RaminMohazzab
Copy link
Author

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!

@hajekj
Copy link
Member

hajekj commented Feb 16, 2021

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.

@RaminMohazzab
Copy link
Author

RaminMohazzab commented Feb 16, 2021

hey, this would be great! My Email: ramin.mohazzab@gympet.net

@RaminMohazzab
Copy link
Author

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]);

@hajekj
Copy link
Member

hajekj commented Feb 16, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants