PnP icon indicating copy to clipboard operation
PnP copied to clipboard

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

Open ncmadhan1989 opened this issue 6 years ago • 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

ncmadhan1989 avatar Jul 22 '19 07:07 ncmadhan1989

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/

bcameron1231 avatar Jul 23 '19 23:07 bcameron1231