1

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?

  • The posted item should be in the item property of the ItemAddResult, maybe do a console.log(iar) to inspect the entire result object. – willman Jan 21 at 18:41
0

Why not log the value directly?

console.log(value,iar.item);

Here is my debug screenshot which can be get from ItemAddResult

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.