使用 search(q='') 语法在文件夹中搜索不会返回任何没有空格的文件

问题描述 投票:0回答:1

所以我有一个程序需要检查驱动器中的文件夹或子文件夹中是否存在文件。尝试着奔跑

/drives/{driveid}/items/{folderid}/search(q='{fullfilename or partialfilename}')
大多数文件不显示任何内容,因为它们不包含空格。正在寻找 .仅显示文件夹中带有空格的异常值文件

sharepoint microsoft-graph-api
1个回答
0
投票

SharePoint REST API 的搜索端点使用关键字查询语言 (KQL) 来执行搜索。在搜索端点中使用 q 参数时,您可能会遇到某些字符的问题。例如,空间可能需要以特定方式处理。

var endpointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/search/query?querytext='example%20file.txt'";
$.ajax({
    url: endpointUrl,
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
        // Process the search results
        console.log(data);
    },
    error: function (error) {
        console.log(error);
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.