Graph API Calls
The graph-call command executes HTTP requests against the Microsoft Graph API.
Basic Usage
Section titled “Basic Usage”msgraph graph-call <METHOD> <URL> [flags]The URL can be a full URL or a relative path starting with /.
Read Operations
Section titled “Read Operations”GET requests work by default without any special flags:
# Current user profilemsgraph graph-call GET /me
# List usersmsgraph graph-call GET /users --select "displayName,mail" --top 10
# Get user's unread messagesmsgraph graph-call GET /me/messages --filter "isRead eq false" --top 5
# List groupsmsgraph graph-call GET /groups --select "displayName,description"
# Get team channelsmsgraph graph-call GET /teams/{team-id}/channelsWrite Operations
Section titled “Write Operations”POST, PUT, and PATCH requests require the --allow-writes flag:
# Send mailmsgraph graph-call POST /me/sendMail \ --body '{"message":{"subject":"Hello","body":{"content":"Hi"},"toRecipients":[{"emailAddress":{"address":"user@example.com"}}]}}' \ --allow-writes
# Update usermsgraph graph-call PATCH /me \ --body '{"jobTitle":"Engineer"}' \ --allow-writesDELETE requests are always blocked for safety.
Query Parameters
Section titled “Query Parameters”| Flag | OData Parameter | Example |
|---|---|---|
--select | $select | --select "displayName,mail" |
--filter | $filter | --filter "isRead eq false" |
--top | $top | --top 10 |
--expand | $expand | --expand "members" |
--orderby | $orderby | --orderby "displayName desc" |
Other Flags
Section titled “Other Flags”| Flag | Description |
|---|---|
--api-version | Use v1.0 or beta (default: beta) |
--body | JSON request body for POST/PUT/PATCH |
--headers | Custom headers as key:value |
--scopes | Additional permission scopes to request |
--output | Output format: json (default) or raw |
Response Format
Section titled “Response Format”Responses are returned as JSON:
{ "statusCode": 200, "body": { "@odata.context": "https://graph.microsoft.com/beta/$metadata#users/$entity", "displayName": "John Doe", "mail": "john@contoso.com" }}Advanced Headers
Section titled “Advanced Headers”Some queries require the ConsistencyLevel header:
# Count usersmsgraph graph-call GET /users/\$count \ --headers "ConsistencyLevel:eventual"
# Search usersmsgraph graph-call GET '/users?$search="displayName:John"' \ --headers "ConsistencyLevel:eventual"Error Handling
Section titled “Error Handling”The tool handles common errors:
- 401: Token expired — run
auth signinagain - 403: Insufficient permissions — automatic incremental consent is attempted
- 404: Resource not found — check the URL
- 429: Rate limited — wait and retry