Testing the Microsoft Graph API with an Entra ID app
Microsoft Graph is the API behind Entra ID (Azure AD), Outlook, Teams and OneDrive. Most integrations start with users and groups: sync the directory, check a group membership, provision an account. Graph's OData conventions ($select, $filter, @odata.nextLink) are consistent once you've seen them, and a test collection makes the permission model concrete.
Step 1: App registration
In the Entra admin center, App registrations ▸ New registration. Under API permissions, add Microsoft Graph Application permissions User.Read.All and Group.Read.All, then Grant admin consent. Under Certificates & secrets, create a client secret.
| Variable | Value |
|---|---|
tenantId | your directory (tenant) id |
graphClientId | the application (client) id |
graphSecret | the client secret, marked as secret |
graph | https://graph.microsoft.com/v1.0 |
On the collection, choose OAuth 2.0, grant Client credentials, token URL https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token, and scope https://graph.microsoft.com/.default. .default means "all application permissions this app was granted"; you can't ask for individual scopes with client credentials.
Step 2: App-only vs delegated
With client credentials the token is app-only: it acts as the application, not a user. So GET /me fails, because there is no "me". Endpoints that need a signed-in user (a user's own mail, /me/joinedTeams) need delegated permissions and the authorization code grant instead. Requestarium supports that grant too, with PKCE.
GET {{graph}}/mepm.test('/me is not available app-only', () => pm.expect(pm.response.code).to.be.oneOf([400, 403]));Step 3: Users with $select and $filter
GET {{graph}}/users?$select=id,displayName,mail,accountEnabled&$filter=accountEnabled eq true&$top=100const body = pm.response.json();
pm.test('users returned', () => pm.expect(body.value.length).to.be.above(0));
pm.test('only the selected fields', () => {
pm.expect(body.value[0]).to.have.property('mail');
pm.expect(body.value[0]).to.not.have.property('jobTitle');
});
if (body['@odata.nextLink']) pm.environment.set('nextLink', body['@odata.nextLink']);Always use $select. Without it Graph returns a default set of fields, which is both more data than you need and different from what you'd guess.
For the next page, request {{nextLink}} as the whole URL. It contains a $skiptoken; don't build it yourself.
Step 4: Counts and search
GET {{graph}}/groups?$filter=startswith(displayName,'eng')&$count=true&$select=id,displayName
ConsistencyLevel: eventualpm.test('count returned', () => pm.expect(pm.response.json()['@odata.count']).to.be.a('number'));Without ConsistencyLevel: eventual, $count and $search on directory objects answer 400 with "Request_UnsupportedQuery". That error confuses everyone the first time.
Step 5: Group membership
GET {{graph}}/groups/{{groupId}}/members?$select=id,mailA check like "the on-call group has at least two members" is a useful scheduled monitor for the directory your access control depends on.
Errors and throttling
Errors are {"error": {"code", "message", "innerError": {"request-id", "date"}}}. Log the request-id: Microsoft support asks for it.
| Status | error.code |
|---|---|
401 | InvalidAuthenticationToken: expired or wrong audience |
403 | Authorization_RequestDenied: the permission is missing or not consented |
404 | Request_ResourceNotFound |
429 | throttled; wait for Retry-After |