Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mvancamp opened this issue Feb 26, 2025 · 0 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@mvancamp
Copy link

mvancamp commented Feb 26, 2025

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

@mvancamp mvancamp added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

1 participant