0

I'm trying to create a list item across another site collection using JavaScript. When trying to call the following function I receive this error.

"request failed. the security validation for this page is invalid. click back in your browser"

function CPECalendar(ApprovalInfo) {
var siteUrl = '/sites/npeeng';
var context = new SP.ClientContext(siteUrl);
var context = SP.ClientContext.get_current();
var oList = context.get_web().get_lists().getByTitle("Activations");
var item = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(item);
oListItem.set_item("Location", "TESTING, PLEASE DISREGARD");
oListItem.update();
context.load(oListItem);
context.executeQueryAsync(silentSuccess, failure);

}

I've read in numerous places about AllowingUnsafeUpdates, but not sure if that pertains to this exact problem or works with js. Is there a viable solution I can use with JavaScript? Thanks.

1

We cannot make cross-sitecollection calls from JSOM in SharePoint 2010.

Here is a similar issue for your reference: https://social.technet.microsoft.com/Forums/en-US/a1853212-62ac-4a15-a47f-e27bc1c35187/hot-to-get-list-which-is-located-in-different-site-collection-using-ecmascript?forum=sharepointgeneralprevious

The scope of client object model is site collection, you cannot access to the content out of the current site collection.

Additionally, making a call from one SharePoint site to another is not allowed because both of these scenarios would result in cross-site scripting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.