Skip to content

Graph client query using filter on SharePoint folder name stopped working (as from 11 Feb 2025)Β #2846

@mvancamp

Description

@mvancamp

Describe the bug

Using a graph client query to get a SharePoint folder information by folder name stopped working. It has been working for months until February 11, 2025. (code block below)

folderSearch = await _graphClient.Drives[driveId]
                                 .Items
                                 .GetAsync(requestConfig => requestConfig.QueryParameters.Filter = $"Name eq '{folderName}'");

It returned the error:
Microsoft.Graph.Models.ODataErrors.ODataError: Filtering non-fields properties other than parentReference/id eq {value} is not supported.

Updating Microsoft Graph nuget package to the latest stable did not solve this issue.

Expected behavior

Until Feb 11, 2025 it returned a DriveItemCollectionResponse. In the folderSearch query driveId and foldername are the parameters from the called method.

How to reproduce

Use the following on a SharePoint Site:

        public async Task<DriveItem> GetFolderByFolderName(string driveId, string folderName)
        {
            DriveItemCollectionResponse folderSearch = null;
            DriveItem folder = null;

            folderSearch = await _graphClient.Drives[driveId]
                                             .Items
                                             .GetAsync(requestConfig => requestConfig.QueryParameters.Filter = $"Name eq '{folderName}'");
            bool folderIsNull = folderSearch == null || folderSearch.Value == null || folderSearch.Value.Count == 0;
            if (!folderIsNull)
                folder = folderSearch.Value[0];

            if (folderIsNull)  // folder does not exist yet, create it
            {
                DriveItem newFolderDriveItemPostRequest = new DriveItem
                {
                    Name = folderName,
                    Folder = new Folder { },
                    AdditionalData = new Dictionary<string, object>
                      {
                          {
                              "@microsoft.graph.conflictBehavior" , "fail"
                          },
                      },
                };
                DriveItem newFolderDriveItem = null;
                newFolderDriveItem = await _graphClient.Drives[driveId]
                                                       .Items
                                                       .PostAsync(newFolderDriveItemPostRequest);
                if (newFolderDriveItem != null)
                {
                    folder = newFolderDriveItem;
                    _logger.LogInformation($"Successful folder creation. folderName: {folderName}, folderId: {newFolderDriveItem.Id}");
                }
            }

            return folder;
        }

SDK Version

5.70.0

Latest version known to work for scenario above?

5.69.0 until date 2025-02-11

Known Workarounds

No response

Debug output

fail: Microsoft.Extensions.Hosting.Internal.Host[9]
BackgroundService failed
Microsoft.Graph.Models.ODataErrors.ODataError: Filtering non-fields properties other than parentReference/id eq {value} is not supported.
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponseAsync(HttpResponseMessage response, Dictionary2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken) at Microsoft.Graph.Drives.Item.Items.ItemsRequestBuilder.GetAsync(Action1 requestConfiguration, CancellationToken cancellationToken)
at SignalsStatisticsOverviewExportMSGraph.SharePointAccess.GetFolderByFolderName(String driveId, String folderName) in C:\Projects\SLS\Projects\SLSSignalsStatisticsExportService_Trunk\SLSSignalsStatisticsExportService\SignalsStatisticsOverviewExportMSGraph\SharePointAccess.cs:line 58
at SignalsStatisticsOverviewExportMSGraph.Worker.ExecuteAsync(CancellationToken stoppingToken) in C:\Projects\SLS\Projects\SLSSignalsStatisticsExportService_Trunk\SLSSignalsStatisticsExportService\SignalsStatisticsOverviewExportMSGraph\Worker.cs:line 41
at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)

Configuration

  • OS: Windows 11 / Windows Server 2022 Datacenter (21H2)
  • Architecture: 64 bit
  • .NET 8.0

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions