Create a list item in another site collection

It is much easier to create or update a list item in another site collection using JSOM. We can easily do it as follows:

I recommend using this method instead of the REST API to create a list item in another site collection.

var listName;
var item;
var itemType;

var otherClientContext = new SP.ClientContext("other site url");
var oList = otherClientContext.get_web().get_lists().getByTitle(listName);
otherClientContext.load(oList);

var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', "SharePoint");
oListItem.update();

own1ClientContext.load(oListItem);
own1ClientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);

function onQuerySucceeded() {
}

function onQueryFailed(sender, args) {
   alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Continue reading “Create a list item in another site collection”