【问题标题】:SiteCore Item WebAPI Remote Call failing with 403SiteCore 项目 WebAPI 远程调用失败并出现 403
【发布时间】:2016-11-16 20:25:54
【问题描述】:

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

下面是示例代码sn-p

   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 sitecore8


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-09
    • 2013-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    • 1970-01-01
    相关资源
    最近更新 更多