I have created one SPFx web part with React framework to add the items from .CSV
file to SharePoint list using PnP JS.
I have used PnP JS item.add()
method to add the item in the list by looping each item.
If any item failed to add in the list I want to keep track of that item. I am using below code:
pnp.sp.web.lists.getByTitle(listdisplayname).items.add(
ColumnInternalname : value
).catch((iar: ItemAddResult) => {
console.log(iar.data.responseBody["odata.error"].message.value,
iar.item);
})
But in the catch I got the response like below.
{"status":400,"statusText":"Bad Request","data":{"responseBody":{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Cannot convert a primitive value to the expected type 'Edm.Boolean'. See the inner exception for more details."}}},"responseHeaders":{}},"name":"ProcessHttpClientResponseException"}
Is it possible to get body (i.e. Parameter we passed in the item.add()
) of that action?
item
property of theItemAddResult
, maybe do aconsole.log(iar)
to inspect the entire result object. – willman Jan 21 '20 at 18:41