Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将sharepoint online search api仅用作应用程序_Sharepoint_Sharepoint Online_Sharepoint Api_Sharepoint Apps_Sharepoint Rest Api - Fatal编程技术网

如何将sharepoint online search api仅用作应用程序

如何将sharepoint online search api仅用作应用程序,sharepoint,sharepoint-online,sharepoint-api,sharepoint-apps,sharepoint-rest-api,Sharepoint,Sharepoint Online,Sharepoint Api,Sharepoint Apps,Sharepoint Rest Api,我正在尝试从应用程序使用sharepoint online search api(/\u api/search)。从Azure门户添加它我看到搜索仅在“委派权限”部分。当我使用用户登录进行测试并批准它时,它运行得很好。 因为我不需要用户登录,所以我找到了这篇文章 这让我相信,搜索只能作为应用程序使用,而不能作为用户使用。我遵循了所有步骤,通过appregnew.aspx创建了应用程序,还通过appinv.aspx添加了另一个权限,因此我请求的权限如下: <AppPermissionReq

我正在尝试从应用程序使用sharepoint online search api(/\u api/search)。从Azure门户添加它我看到搜索仅在“委派权限”部分。当我使用用户登录进行测试并批准它时,它运行得很好。 因为我不需要用户登录,所以我找到了这篇文章

这让我相信,搜索只能作为应用程序使用,而不能作为用户使用。我遵循了所有步骤,通过appregnew.aspx创建了应用程序,还通过appinv.aspx添加了另一个权限,因此我请求的权限如下:

<AppPermissionRequests AllowAppOnlyPolicy="true">
    <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
    <AppPermissionRequest Scope="http://sharepoint/search" Right="QueryAsUserIgnoreAppPrincipal" />
</AppPermissionRequests>
,原因[{“error\u description”:“由于内部错误,服务器无法处理该请求。有关错误的详细信息,请启用IncludeExceptionDetailInFaults(从ServiceBehaviorAttribute或从配置行为中)以将异常信息发送回客户端,或根据Microsoft.NET Framework SDK文档打开跟踪并检查服务器跟踪日志。“}]

既然这是sharepoint online,我没有服务器,也没有使用.NET framework,那么还有什么其他方法可以调试它呢?你知道我做错了什么吗


任何帮助都将不胜感激

也许您可以使用Java调用SharePoint Search Api并显示结果(但我们需要花很多时间来研究这一点,存在许多不确定性。)

您的最佳选择是使用VisualStudio测试SharePoint加载项。Microsoft在这方面提供了更多支持,您可以使用现成的模板

您可以使用SharePoint为搜索加载项提供的各种搜索相关API:
.NET客户端对象模型(CSOM) 关键LIB: Microsoft.SharePoint.Client.Search.dll Silverlight CSOM 关键LIB: Microsoft.SharePoint.Client.Search.Silverlight.dll ECMAScript(JavaScript,JScript)对象模型(JSOM) 关键LIB: SP.search.js

搜索RESTAPI

一些演示代码: 客户端对象模型(CSOM) C#

休息 HTTP获取请求 HTML

HTTP POST请求 HTML

然后通过VisualStudio和“Napa”Office 365开发工具设置权限

有关搜索加载项的详细信息:

我确实在问题中粘贴了我看到的错误,“{”error\u description:“由于内部错误,服务器无法处理请求…”" . 我不是在VisualStudio上开发。也许最初的问题是,是否有可能在没有用户的情况下使用查询API?基本上,SharePoint仅适用于内部用户。因此,为了安全起见,我们不能在没有用户的情况下使用它。(如果我们不是开发人员(但it管理员),我们似乎可以设置一些外部或匿名用户来查看搜索结果,但我忘了在哪里看到文档)
Future<AuthenticationResult> future = context.acquireToken(
                resource, new ClientCredential(clientId,
                        clientSecret), null);
using (ClientContext clientContext = new ClientContext("http://localhost"))
{
    KeywordQuery keywordQuery = new KeywordQuery(clientContext);
    keywordQuery.QueryText = "*";
    SearchExecutor searchExecutor = new SearchExecutor(clientContext);
    ClientResult<ResultTableCollection> results = 
        searchExecutor.ExecuteQuery(keywordQuery);
    clientContext.ExecuteQuery();
}
var keywordQuery = new
Microsoft.SharePoint.Client.Search.Query.KeywordQuery(context);
keywordQuery.set_queryText('SharePoint');
var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(context);
results = searchExecutor.executeQuery(keywordQuery);
context.executeQueryAsync(onQuerySuccess, onQueryFail);
http://mylocalhost/_api/search/query?querytext='SharePoint'
{
'__metadata' : {'type' : 'Microsoft.Office.Server.Search.REST.SearchRequest'},
'Querytext' : 'SharePoint'
}