pnp/PnP

Need to create list items in List present in different site collection using pnp js

ncmadhan1989 opened this issue · 1 comments

Need to create list items in List present in different site collection using pnp js

$.ajax({
url: otherSiteUrl + "/_api/contextinfo",
type: "POST",
headers: {
"Accept": "application/json;odata=verbose"
},
success: function (contextData) {
$.ajax({
url: otherSiteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items?@target='" + otherSiteUrl + "'",
method: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(item),
async: false,
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(contextData.d.GetContextWebInformation.FormDigestValue)
},
success: function (data) {
alert('success');
},
error: function (jqXHR, textStatus, errorThrown) {
alert('error');
}
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert('error');
}
});
the above is Rest Sample,kindly provide equivalent for Pnp Js

I think you meant to post this over in the PnPJs Repository https://github.com/pnp/pnpjs/issues

However, the information for getting access to another Site Collection web object is found in the documentation https://pnp.github.io/pnpjs/sp/docs/webs/

Subsequently, you'll want to look into the items documentations to see how to create list items from the web object.
https://pnp.github.io/pnpjs/sp/docs/items/