【问题标题】:Create Item by using Item web api使用 Item web api 创建 Item
【发布时间】:2015-07-29 13:29:59
【问题描述】:

我想知道如何使用sitecore item web api实现javascript方法来创建新项目。我正在尝试下面的代码。

但在浏览器控制台中显示此错误: XMLHttpRequest 无法加载http://myproject/-/item/v1/sitecore/Content/Home?name=MyItem5&template=Sample/Sample%20Item&sc_database=master。 Access-Control-Allow-Headers 不允许请求标头字段 X-Scitemwebapi-Password。

谁能帮帮我!!!!!!

function createItem(){
jQuery.ajax({
crossDomain: 'true',
type: 'POST',
url: 'http://myproject/-/item/v1/sitecore/Content/Home?name=MyItem5&template=Sample/Sample Item&sc_database=master',
dataType: 'JSON',
contentType: 'application/x-www-form-urlencoded',

     headers:{
     "X-Scitemwebapi-Username":"sitecore\\Admin",
     "X-Scitemwebapi-Password":"b",
    },


success: function(data) {

    alert(JSON.stringify(data));
},
error: function(res, error){
alert(JSON.stringify(res))
    alert(res+ ' something is wrong');
 }

}); }

【问题讨论】:

    标签: sitecore


    【解决方案1】:

    确保您的Sitecore.ItemWebApi.config 中有这些设置

    itemwebapi.mode="StandardSecurity"
    itemwebapi.allowanonymousaccess="false"/>
    

    【讨论】:

    • 感谢golden grahams。我尝试了您的建议。但这不像安全配置问题。似乎是跨域或标头请求的问题。
    • 好的,值得一试。要尝试的另一件事 - 将标题添加到自定义标题列表中。看看这个stackoverflow.com/questions/12409600/…
    • golden grahams,感谢您的热情回复。我仍然有麻烦。
    • 请求状态为 200。这意味着请求成功,但 sitecore 的身份验证出现问题。
    猜你喜欢
    • 2015-03-22
    • 2014-12-22
    • 2014-10-05
    • 2014-10-09
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 2016-07-21
    • 1970-01-01
    相关资源
    最近更新 更多