Processing failed:Invalid filter clause: Syntax error

Carlos Jahir Carreño Hernandez 125 Reputation points
2023-11-14T15:08:05.1833333+00:00

When running my code with filters brought from MS Graph Explorer, the following error appears: "Processing failed: Invalid filter clause: Syntax error."

var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
            try
            {
                var devices = await graphClient.Devices.GetAsync((requestConfiguration) =>
                {
                    requestConfiguration.QueryParameters.Filter = "startswith(operatingSystem,'Win'),profileType eq 'RegisteredDevice',mdmAppId ne null"; // Corrected line
                    requestConfiguration.QueryParameters.Count = true;
                    requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
                });
                Console.WriteLine(devices);

Everything is according to what MS Graph has provided me. Could you help me because it's throwing that error? Thank you.

User's image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,855 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 41,286 Reputation points
    2023-11-15T03:14:05.5933333+00:00

    Hi @carlos carreno

    From my testing, it seems that filtering the mdmAppId attribute is not supported. As a solution, try getting the device set and filtering it locally.

    Code example:

    var devices = await graphClient.Devices.GetAsync();
    
    foreach (var device in devices.Value) {
    
        if (device.OperatingSystem.StartsWith("Win") && device.ProfileType is "RegisteredDevice" && device.MdmAppId != null) {
    
            Console.WriteLine(device.Id);
          
        }
    }
    

    User's image

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.