This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge

Microsoft Graph supports optional query parameters that you can use to specify and control the amount of data returned in a response. The support for the exact query parameters varies from one API operation to another, and depending on the API, can differ between the v1.0 and beta endpoints.

On the beta endpoint, the $ prefix is optional. For example, instead of $filter , you can use filter . On the v1 endpoint, the $ prefix is optional for only a subset of APIs. For simplicity, always include $ if using the v1 endpoint.

Query parameters can be OData system query options or other query parameters.

OData system query options

A Microsoft Graph API operation might support one or more of the following OData system query options. These query options are compatible with the OData V4 query language and are supported in only GET operations.

Click the examples to try them in Graph Explorer .

Description Example $skip Indexes into a result set. Also used by some APIs to implement paging and can be used together with $top to manually page results. /me/messages?$skip=11 Sets the page size of results. /users?$top=2

To know the OData system query options that an API and its properties support, see the Properties table in the resource page, and the Optional query parameters section of the LIST and GET operations for the API.

Other query parameters

Description Example $skipToken Retrieves the next page of results from result sets that span multiple pages. (Some APIs use $skip instead.) /users?$skiptoken=X%274453707402000100000017...

Other OData URL capabilities

The following OData 4.0 capabilities are URL segments, not query parameters.

Description Example $count Retrieves the integer total of the collection. GET /users/$count
GET /groups/{id}/members/$count Updates entities membership to a collection. POST /groups/{id}/members/$ref $value Retrieves or updates the binary value of an item. GET /me/photo/$value $batch Combine multiple HTTP requests into a batch request. POST /$batch

Encoding query parameters

The values of query parameters should be percent-encoded as per RFC 3986 . For example, all reserved characters in query strings must be percent-encoded. Many HTTP clients, browsers, and tools (such as the Graph Explorer ) will help you with this. If a query is failing, one possible cause is failure to encode the query parameter values appropriately. In some cases, you may have to double-encode the values.

For example, an unencoded URL looks like this:

JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Users.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Filter = "startswith(givenName,%20'J')"; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestFilter := "startswith(givenName,%20'J')" requestParameters := &graphconfig.UsersRequestBuilderGetQueryParameters{ Filter: &requestFilter, configuration := &graphconfig.UsersRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Users().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); UserCollectionPage users = graphClient.users() .buildRequest() .filter("startswith(givenName, 'J')") .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new UsersRequestBuilderGetRequestConfiguration(); $queryParameters = UsersRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->filter = "startswith(givenName,%20'J')"; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->users()->get($requestConfiguration); var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Users.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Filter = "startswith(givenName,%20'J')"; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestFilter := "startswith(givenName,%20'J')" requestParameters := &graphconfig.UsersRequestBuilderGetQueryParameters{ Filter: &requestFilter, configuration := &graphconfig.UsersRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Users().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); UserCollectionPage users = graphClient.users() .buildRequest() .filter("startswith(givenName, 'J')") .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new UsersRequestBuilderGetRequestConfiguration(); $queryParameters = UsersRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->filter = "startswith(givenName,%20'J')"; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->users()->get($requestConfiguration); var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Users.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Filter = "startswith(givenName,%20'J')"; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestFilter := "startswith(givenName,%20'J')" requestParameters := &graphconfig.UsersRequestBuilderGetQueryParameters{ Filter: &requestFilter, configuration := &graphconfig.UsersRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Users().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); UserCollectionPage users = graphClient.users() .buildRequest() .filter("startswith(givenName, 'J')") .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new UsersRequestBuilderGetRequestConfiguration(); $queryParameters = UsersRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->filter = "startswith(givenName,%20'J')"; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->users()->get($requestConfiguration); var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Messages.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Filter = "subject eq 'let''s meet for lunch?'"; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestFilter := "subject eq 'let''s meet for lunch?'" requestParameters := &graphconfig.ItemMessagesRequestBuilderGetQueryParameters{ Filter: &requestFilter, configuration := &graphconfig.ItemMessagesRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Messages().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MessageCollectionPage messages = graphClient.me().messages() .buildRequest() .filter("subject eq 'let''s meet for lunch?'") .get(); let messages = await client.api('/me/messages') .filter('subject eq \'let\'\'s meet for lunch?\'') .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new MessagesRequestBuilderGetRequestConfiguration(); $queryParameters = MessagesRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->filter = "subject eq 'let''s meet for lunch?'"; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->messages()->get($requestConfiguration);

count parameter

Use the $count query parameter to retrieve the count of the total number of items in a collection or matching an expression. $count can be used in the following ways:

  • As a query string parameter with the syntax $count=true to include a count of the total number of items in a collection alongside the page of data values returned from Microsoft Graph. For example, users?$count=true .
  • As a URL segment to retrieve only the integer total of the collection. For example, users/$count .
  • In a $filter expression with equality operators to retrieve a collection of data where the filtered property is an empty collection. See Use the $filter query parameter to filter a collection of objects .
  • On resources that derive from directoryObject , $count is only supported in an advanced query. See Advanced query capabilities in Azure AD directory objects .
  • Use of $count is not supported in Azure AD B2C tenants.
  • For example, the following request returns both the contact collection of the current user, and the number of items in the contact collection in the @odata.count property.

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Contacts.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Count = true; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestCount := true requestParameters := &graphconfig.ItemContactsRequestBuilderGetQueryParameters{ Count: &requestCount, configuration := &graphconfig.ItemContactsRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Contacts().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); ContactCollectionPage contacts = graphClient.me().contacts() .buildRequest() .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new ContactsRequestBuilderGetRequestConfiguration(); $queryParameters = ContactsRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->count = true; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->contacts()->get($requestConfiguration);

    The $count query parameter is supported for collections of the following frequently used resources and their relationships that derive from directoryObject and only in advanced queries :

  • administrativeUnit
  • application
  • orgContact
  • device
  • group
  • servicePrincipal
  • expand parameter

    Many Microsoft Graph resources expose both declared properties of the resource as well as its relationships with other resources. These relationships are also called reference properties or navigation properties, and they can reference either a single resource or a collection of resources. For example, the mail folders, manager, and direct reports of a user are all exposed as relationships.

    Normally, you can query either the properties of a resource or one of its relationships in a single request, but not both. You can use the $expand query string parameter to include the expanded resource or collection referenced by a single relationship (navigation property) in your results. Only one relationship can be expanded in a single request.

    The following example gets root drive information along with the top-level child items in a drive:

    JavaScript PowerShell GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); DriveItem driveItem = graphClient.me().drive().root() .buildRequest() .expand("children") .get();

    With some resource collections, you can also specify the properties to be returned in the expanded resources by adding a $select parameter. The following example performs the same query as the previous example but uses a $select statement to limit the properties returned for the expanded child items to the id and name properties.

    JavaScript PowerShell GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); DriveItem driveItem = graphClient.me().drive().root() .buildRequest() .expand("children($select=id,name)") .get();
  • Not all relationships and resources support the $expand query parameter. For example, you can expand the directReports , manager , and memberOf relationships on a user, but you cannot expand its events , messages , or photo relationships. Not all resources or relationships support using $select on expanded items.

  • With Azure AD resources that derive from directoryObject , like user and group , $expand typically returns a maximum of 20 items for the expanded relationship and has no @odata.nextLink . See more known issues .

  • $expand is not currently supported with advanced queries .

    filter parameter

    Use the $filter query parameter to retrieve just a subset of a collection. For guidance on using $filter , see Use the $filter query parameter to filter a collection of objects .

    format parameter

    Use the $format query parameter to specify the media format of the items returned from Microsoft Graph.

    For example, the following request returns the users in the organization in the json format:

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Users.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Format = "json"; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestFormat := "json" requestParameters := &graphconfig.UsersRequestBuilderGetQueryParameters{ Format: &requestFormat, configuration := &graphconfig.UsersRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Users().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); UserCollectionPage users = graphClient.users() .buildRequest() .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new UsersRequestBuilderGetRequestConfiguration(); $queryParameters = UsersRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->format = "json"; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->users()->get($requestConfiguration);

    The $format query parameter supports a number of formats (for example, atom, xml, and json) but results may not be returned in all formats.

    orderby parameter

    Use the $orderby query parameter to specify the sort order of the items returned from Microsoft Graph. The default order is ascending order.

    For example, the following request returns the users in the organization ordered by their display name:

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Users.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Orderby = new string []{ "displayName" }; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestParameters := &graphconfig.UsersRequestBuilderGetQueryParameters{ Orderby: [] string {"displayName"}, configuration := &graphconfig.UsersRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Users().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); UserCollectionPage users = graphClient.users() .buildRequest() .orderBy("displayName") .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new UsersRequestBuilderGetRequestConfiguration(); $queryParameters = UsersRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->orderby = ["displayName"]; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->users()->get($requestConfiguration); var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Messages.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Orderby = new string []{ "from/emailAddress/address" }; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestParameters := &graphconfig.ItemMessagesRequestBuilderGetQueryParameters{ Orderby: [] string {"from/emailAddress/address"}, configuration := &graphconfig.ItemMessagesRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Messages().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MessageCollectionPage messages = graphClient.me().messages() .buildRequest() .orderBy("from/emailAddress/address") .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new MessagesRequestBuilderGetRequestConfiguration(); $queryParameters = MessagesRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->orderby = ["from/emailAddress/address"]; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->messages()->get($requestConfiguration);

    To sort the results in ascending or descending order, append either asc or desc to the field name, separated by a space; for example, ?$orderby=name%20desc . If the sort order is not specified, the default (ascending order) is inferred.

    With some APIs, you can order results on multiple properties. For example, the following request orders the messages in the user's Inbox, first by the name of the person who sent it in descending order (Z to A), and then by subject in ascending order (default).

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.MailFolders["{mailFolder-id}"].Messages.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Orderby = new string []{ "from/emailAddress/name desc","subject" }; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestParameters := &graphconfig.ItemMailFolderItemMessagesRequestBuilderGetQueryParameters{ Orderby: [] string {"from/emailAddress/name desc","subject"}, configuration := &graphconfig.ItemMailFolderItemMessagesRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().MailFolders().ByMailFolderId("mailFolder-id").Messages().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MessageCollectionPage messages = graphClient.me().mailFolders("Inbox").messages() .buildRequest() .orderBy("from/emailAddress/name desc,subject") .get(); const client = Client.init(options); let messages = await client.api('/me/mailFolders/Inbox/messages') .orderby('from/emailAddress/name desc,subject') .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new MessagesRequestBuilderGetRequestConfiguration(); $queryParameters = MessagesRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->orderby = ["from/emailAddress/name desc","subject"]; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->mailFoldersById('mailFolder-id')->messages()->get($requestConfiguration);

    When you specify $filter the server will infer a sort order for the results. If you use both $orderby and $filter to get messages, because the server always infers a sort order for the results of a $filter , you must specify properties in certain ways .

    The following example shows a query filtered by the subject and importance properties, and then sorted by the subject , importance , and receivedDateTime properties in descending order.

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Messages.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Filter = "Subject eq 'welcome' and importance eq 'normal'"; requestConfiguration.QueryParameters.Orderby = new string []{ "subject","importance","receivedDateTime desc" }; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestFilter := "Subject eq 'welcome' and importance eq 'normal'" requestParameters := &graphconfig.ItemMessagesRequestBuilderGetQueryParameters{ Filter: &requestFilter, Orderby: [] string {"subject","importance","receivedDateTime desc"}, configuration := &graphconfig.ItemMessagesRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Messages().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MessageCollectionPage messages = graphClient.me().messages() .buildRequest() .filter("Subject eq 'welcome' and importance eq 'normal'") .orderBy("subject,importance,receivedDateTime desc") .get(); let messages = await client.api('/me/messages') .filter('Subject eq \'welcome\' and importance eq \'normal\'') .orderby('subject,importance,receivedDateTime desc') .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new MessagesRequestBuilderGetRequestConfiguration(); $queryParameters = MessagesRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->filter = "Subject eq 'welcome' and importance eq 'normal'"; $queryParameters->orderby = ["subject","importance","receivedDateTime desc"]; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->messages()->get($requestConfiguration);

    Combining $orderby and $filter query parameters is supported for directory objects. See Advanced query capabilities in Azure AD directory objects .

    search parameter

    Use the $search query parameter to restrict the results of a request to match a search criterion. It's syntax and behavior varies from one API operation to another. To see the syntax for $search across different resources, see Use the $search query parameter to match a search criterion .

    select parameter

    Use the $select query parameter to return a set of properties that are different than the default set for an individual resource or a collection of resources. With $select , you can specify a subset or a superset of the default properties.

    For example, when retrieving the messages of the signed-in user, you can specify that only the from and subject properties be returned:

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Messages.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Select = new string []{ "from","subject" }; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestParameters := &graphconfig.ItemMessagesRequestBuilderGetQueryParameters{ Select: [] string {"from","subject"}, configuration := &graphconfig.ItemMessagesRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Messages().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MessageCollectionPage messages = graphClient.me().messages() .buildRequest() .select("from,subject") .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new MessagesRequestBuilderGetRequestConfiguration(); $queryParameters = MessagesRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->select = ["from","subject"]; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->messages()->get($requestConfiguration);

    Important

    In general, we recommend that you use $select to limit the properties returned by a query to those needed by your app. This is especially true of queries that might potentially return a large result set. Limiting the properties returned in each row will reduce network load and help improve your app's performance.

    In v1.0 , some Azure AD resources that derive from directoryObject , like user and group , return a limited, default subset of properties on reads. For these resources, you must use $select to return properties outside of the default set.

    skip parameter

    Use the $skip query parameter to set the number of items to skip at the start of a collection. For example, the following request returns events for the user sorted by date created, starting with the 21st event in the collection:

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Events.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Orderby = new string []{ "createdDateTime" }; requestConfiguration.QueryParameters.Skip = 20; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestSkip := int32(20) requestParameters := &graphconfig.ItemEventsRequestBuilderGetQueryParameters{ Orderby: [] string {"createdDateTime"}, Skip: &requestSkip, configuration := &graphconfig.ItemEventsRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Events().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); EventCollectionPage events = graphClient.me().events() .buildRequest() .orderBy("createdDateTime") .skip(20) .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new EventsRequestBuilderGetRequestConfiguration(); $queryParameters = EventsRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->orderby = ["createdDateTime"]; $queryParameters->skip = 20; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->events()->get($requestConfiguration);

    Some Microsoft Graph APIs, like Outlook Mail and Calendars ( message , event , and calendar ), use $skip to implement paging. When results of a query span multiple pages, these APIs will return an @odata:nextLink property with a URL that contains a $skip parameter. You can use this URL to return the next page of results. To learn more, see Paging .

    Directory objects such as user , group , and application don't support $skip .

    skipToken parameter

    Some requests return multiple pages of data, either due to server-side paging or due to the use of the $top parameter to limit the page size of the response. Many Microsoft Graph APIs use the skipToken query parameter to reference subsequent pages of the result.
    The $skiptoken parameter contains an opaque token that references the next page of results and is returned in the URL provided in the @odata.nextLink property in the response. To learn more, see Paging .

    If you're using OData Count (adding $count=true in the query string) for queries against directory objects, the @odata.count property is present only in the first page.

    The ConsistencyLevel header required for advanced queries against directory objects is not included by default in subsequent page requests. It must be set explicitly in subsequent pages.

    top parameter

    Use the $top query parameter to specify the number of items to be included in the result.

    If more items remain in the result set, the response body will contain an @odata.nextLink parameter. This parameter contains a URL that you can use to get the next page of results. To learn more, see Paging .

    The minimum value of $top is 1 and the maximum depends on the corresponding API.

    For example, the following list messages request returns the first five messages in the user's mailbox:

    JavaScript PowerShell var graphClient = new GraphServiceClient(requestAdapter); var result = await graphClient.Me.Messages.GetAsync((requestConfiguration) => requestConfiguration.QueryParameters.Top = 5; "context" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" graphconfig "github.com/microsoftgraph/msgraph-sdk-go/users" //other-imports graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes) requestTop := int32(5) requestParameters := &graphconfig.ItemMessagesRequestBuilderGetQueryParameters{ Top: &requestTop, configuration := &graphconfig.ItemMessagesRequestBuilderGetRequestConfiguration{ QueryParameters: requestParameters, result, err := graphClient.Me().Messages().Get(context.Background(), configuration) GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MessageCollectionPage messages = graphClient.me().messages() .buildRequest() .top(5) .get(); // THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY $graphServiceClient = new GraphServiceClient($requestAdapter); $requestConfiguration = new MessagesRequestBuilderGetRequestConfiguration(); $queryParameters = MessagesRequestBuilderGetRequestConfiguration::createQueryParameters(); $queryParameters->top = 5; $requestConfiguration->queryParameters = $queryParameters; $result = $graphServiceClient->me()->messages()->get($requestConfiguration);

    The ConsistencyLevel header required for advanced queries against directory objects is not included by default in subsequent page requests. It must be set explicitly in subsequent pages.

    Error handling for query parameters

    Some requests will return an error message if a specified query parameter is not supported. For example, you cannot use $expand on the user/photo relationship.

    https://graph.microsoft.com/v1.0/me?$expand=photo
        "error":{
            "code":"ExpandNotSupported",
            "message":"Expand is not allowed for property 'Photo' according to the entity schema.",
            "innerError":{
                "request-id":"1653fefd-bc31-484b-bb10-8dc33cb853ec",
                "date":"2017-07-31T20:55:01"
    

    However, it is important to note that query parameters specified in a request might fail silently. This can be true for unsupported query parameters as well as for unsupported combinations of query parameters. In these cases, you should examine the data returned by the request to determine whether the query parameters you specified had the desired effect.

    See also

  • Advanced query capabilities on Azure AD directory objects
  • Use the $search query parameter to match a search criterion
  • Query parameter limitations
  • Training module: Optimize data usage when using Microsoft Graph with query parameters
  •