1
votes

I want to know how implement javascript method to create new item by using sitecore item web api.I am trying for below code my self.

But in the browser console show this error: XMLHttpRequest cannot load http://myproject/-/item/v1/sitecore/Content/Home?name=MyItem5&template=Sample/Sample%20Item&sc_database=master. Request header field X-Scitemwebapi-Password is not allowed by Access-Control-Allow-Headers.

Please can anyone help me!!!!!!!

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');
 }

}); }

1

1 Answers

1
votes

Make sure you have these settings in your Sitecore.ItemWebApi.config

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