Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

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

Open
ncmadhan1989 opened this issue Jul 22, 2019 · 1 comment

Comments

@ncmadhan1989
Copy link

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

@bcameron1231
Copy link

bcameron1231 commented Jul 23, 2019

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/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants