MS Graph Search API Error: Value cannot be null. (Parameter 'searchHistoryManager')

Michael Nickol 5 Reputation points
2025-03-12T12:52:49.01+00:00

First of all:

Uploading / downloading files to our SharePoint Online site out of an Azure Synapse Analytics Python notebook with a generated OAuth2 token works flawlessly, so this is not a firewall / token generation issue or something alike.

My Situation:

I am trying to list all files in our company's SharePoint Online folder that end with *.xlsx via MS Graph API Search (as such an "endsWith" search is not possible with the regular MS Graph API filters).

I am using an Azure enterprise application with application permission.
The app permissions are currently configured as follows (screenshot):
User's image

The site I want to look for files is within the "Shared Documents" SharePoint folder of the site.

The request body of my MS Graph API search request looks as follows:
User's image

The response is as follows:

<Response [500]> {'error': {'code': 'System.ArgumentNullException', 'message': "Value cannot be null. (Parameter 'searchHistoryManager')", 'target': 'Microsoft.Griffin.WebService.Search.SearchHistoryWriters.BaseSearchHistoryWriter`3[TRequest,TSettings,TResponse].Validate'}, 'Instrumentation': {'TraceId': '3593fc9f-4b75-b421-da01-9dbb291acb49'}}

Please help.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rajat Vashistha-MSFT 1,780 Reputation points Microsoft External Staff
    2025-03-12T16:18:44.08+00:00

    Hi Michael Nickol,

    Thanks for reaching out to Microsoft!

    I attempted to reproduce the scenario on my end, and I was able to achieve success. Since your requirement is to find .xlsx files in SharePoint Online folder, please try formatting the JSON body as shown belowUser's image

    Below are my repro results by using the Delegated Permission and same worked fine using Application Permission as well:

    User's image

    User's image As you pointed out in your comment, the issue was due to a 'copy & paste' error in your Python code. The request method was still set to 'put' from another piece of code you reused. Once you changed it to 'post', it worked perfectly

    You can refer to the following document for further details: Use the Microsoft Search API to search OneDrive and SharePoint content

    Hope this helps.

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


Your answer

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