首页 > 解决方案 > SP 365 rest search api 返回“500 内部服务器错误”以使用 HTTP POST

问题描述

我们的产品使用 SP 365 搜索 API。我们的一些客户报告说,在使用以下搜索 API 时:'/_api/search/postquery' 和正文:

    {'request': {
         'Querytext':'test',
         'SourceId':'8413cd39-2156-4e00-b54d-11efd9abdb89', 
         'RowLimit':400,
         'SelectProperties':{
           'results':['Title','Path','Description','Write','Rank','Size']}, 
        'TrimDuplicates':true,
        'ClientType':'Custom',
        'Culture':1030,
        'SortList':{'results':[{'Property':'Rank','Direction':'1'}]}
     }}

返回带有错误文本的 HTTP 状态代码 500(在 json 响应中):“发生未知错误。” 但是,如果在查询中添加一个条件以将其限制为特定的 SP 列表,例如:

     {'request': {
         'Querytext':'test AND "ListId":{A7B96B28-6062-435B-A2EE-4792512A95A1}',
         'SourceId':'8413cd39-2156-4e00-b54d-11efd9abdb89', 
         'RowLimit':400,
         'SelectProperties':{
           'results':['Title','Path','Description','Write','Rank','Size']}, 
        'TrimDuplicates':true,
        'ClientType':'Custom',
        'Culture':1030,
        'SortList':{'results':[{'Property':'Rank','Direction':'1'}]}
     }}

然后查询运行良好。

这发生在特定租户,如“pfgroupas.sharepoint.com”。这个 API 调用已经工作多年了(从 SP 2013 开始)并且在最近几天被打破了。

标签: sharepoint-rest-apimicrosoft365

解决方案


事实证明,对于某些租户,如果您指定“SortList”参数,内部服务器错误就会显现出来。如果您在没有它的情况下创建查询,例如:

{'request': {
     'Querytext':'test',
     'SourceId':'8413cd39-2156-4e00-b54d-11efd9abdb89', 
     'RowLimit':400,
     'SelectProperties':{
       'results':['Title','Path','Description','Write','Rank','Size']}, 
    'TrimDuplicates':true,
    'ClientType':'Custom',
    'Culture':1030
 }}

然后一切正常。在我看来,这就像一个服务器端错误。


推荐阅读