1

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 Answer 1

1

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

itemwebapi.mode="StandardSecurity"
itemwebapi.allowanonymousaccess="false"/>
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks golden grahams.I tried for your suggestion.But it is not like security configuration issue.seems like issue of cross domain or header request.
Ok, was worth a shot. Another thing to try - Add the headers to the list of custom headers. Have a look at this stackoverflow.com/questions/12409600/…
golden grahams, Thanks for ur kindly reply.Still I am in trouble.
request states 200.It means request successful but issue with authentication for sitecore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.