gpt4 book ai didi

SiteCore 项目 WebAPI 远程调用失败,返回 403

转载 作者:行者123 更新时间:2023-12-02 20:55:11 24 4
gpt4 key购买 nike

大家好,我正在尝试远程调用 SiteCore Item Web API,其中Sitecore 未安装且无法从远程计算机调用服务。我从远程计算机收到 403,但从 Sitecore 机器收到响应 200。

下面是示例代码片段

   namespace SiteCoreApi
{
class Program
{
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create ("http://dpc/sitecore/api/ssc/item/?path=/sitecore/content/home");

request.Headers["X-Scitemwebapi-Username"] = @"sitecore\admin";
request.Headers["X-Scitemwebapi-Password"] = "b";

try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.Write(String.Format("Content length is {0}", response.ContentLength));
Console.Write(String.Format("Content type is {0}", response.ContentType));
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
Console.Write("<br /> Response stream received. <br />");
Console.Write(readStream.ReadToEnd());
Console.ReadLine();

}

catch(Exception ex)
{
Console.Write(ex.Message);
}

}
}

最佳答案

我认为发生这种情况是因为 sitecore 服务安全策略默认设置为 ServicesLocalOnlyPolicy,您需要将其更改为 ServicesOnPolicy 您可以在以下位置找到这些配置:App_Config/include/Sitecore.Services.client.config,但要小心更改此文件中的设置可能会影响您的 Sitecore 安装的安全性

关于SiteCore 项目 WebAPI 远程调用失败,返回 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40617637/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com