Sitecore ItemWebApi - "Access to site is not granted"

标签 sitecore sitecore7 sitecore7.1

Sitecore ItemWebApi 专家,

为什么每次我尝试发出 Sitecore ItemWebApi 请求时都会收到“未授予访问网站权限”的响应?

以下是我的 Sitecore.ItemWebApi.config 中的安全设置

<site name="website">
    <patch:attribute name="itemwebapi.mode">StandardSecurity</patch:attribute>
    <patch:attribute name="itemwebapi.access">ReadOnly</patch:attribute>
    <patch:attribute name="itemwebapi.allowanonymousaccess">false</patch:attribute>
  </site>
</sites>

以下是我设置 ItemWebApi 请求的方法(请注意,我使用了假用户名、密码和 GUID 来实现堆栈溢出):

  var client = new WebClient();

  var n = new NameValueCollection();
  n["X-Scitemwebapi-Username"] = "extranet\\Sample_Username";
  n["X-Scitemwebapi-Password"] = "SamplePassword";

  client.Headers.Add(n);

  var result = client.DownloadString(
            "http://localhost:11111/-/item/v1/?sc_itemid={11111111-1111-1111-1111-111111111111}&scope=c");

我从请求中得到的响应始终是:

Access to site is not granted

我使用的是 sitecore 7.1。

最佳答案

事实证明我使用了错误的用户密码。我的问题中的上面的代码完全有效,并且将返回一个 json 响应,其中包含有关 sitecore 项目的所需信息。

我还想补充一点,您需要验证您尝试进行身份验证的 sitecore 用户是否已在 sitecore 中“启用”。我通过 sitecore 包为我的 Item Web Api 添加了一个用户,但不知道当您这样做时,sitecore 默认情况下会禁用该用户。实际上,您必须在用户处于事件状态之前手动“启用”该用户。

关于Sitecore ItemWebApi - "Access to site is not granted",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23397287/

相关文章:

Sitecore 高可用性架构

lucene - 无法创建类型为 : Sitecore. ContentSearch.LuceneProvider.Analyzers.DefaultPerFieldAnalyzer 的实例。找不到匹配的构造函数

Sitecore 工作流程 - 发布处于草稿状态的项目

iis - 无法读取 Sitecore 配置

sitecore - 关于 Sitecore 发布 :end:remote event 的简单问题

sitecore - 在渲染参数模板字段上设置可查询源

c# - Sitecore-Web Api 用户认证

c# - Sitecore Powershell 反序列化 - Core DB

sitecore - 为 Sitecore 设置开发环境的最佳方法是什么

json - Sitecore 和 Json 序列化 - 奇怪的转换