I'm trying to add/update an item back to the ArcGIS Portal using the portal API, in much the same way as you would when doing 'Configure Application'. I am trying to use the update item call to send an item back to the server via POST.
In Chrome I am getting the error "Origin localhost:53657 is not allowed by Access-Control-Allow-Origin". In IE I get the error "Access Denied" and FF nothing happens.
I understand about cross origin, but I thought the ESRI server must support it otherwise how would we make this post? I can't use jsonp since this does not support post
Edit: If I try to do AddItem I get the error: XMLHttpRequest cannot load https://yyy.maps.arcgis.com/sharing/content/users/yyy_wilton_d/addItem. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.
Can anyone see what I am doing wrong? Does anybody have a sample? Or how can I check that the ESRI server is set up to support CORS?
esri.config.defaults.io.corsEnabledServers.push("https://yyy.maps.arcgis.com/");
var apiID = 07d5de8305cf47c99057ca1336e2yyy
var xhrArgs = {
url: 'https://yyy.maps.arcgis.com/rest/content/users/yyy_wilton_d/items/' + apiID + '/update',
token: this.token,
overwrite: true,
content: cont,
text: dojo.toJson(cont),
handleAs: "json",
load: function (data) {
debugger;
},
error: function (error) {
debugger;
}
};
dojo.xhrPost(xhrArgs);