Forum Discussion
SpSouv
Sep 04, 2022Copper Contributor
How do I get item attachment using PnP caml?
I have this in my solution trying to use the accordion web part. The query I have, I've tried to dd attachment options with no luck: this.state = {
items: new Array<any>(),
cho...
kalpeshvaghela
Sep 05, 2022Iron Contributor
There is no method available where you can get all attachments for all the list items from the list at single go. You need to do individual query for each item to get attachment URLs
You can use below code to get attachment of particular items:
let item=sp.web.lists.getByTitle("TestList").items.getById(13);
item.attachmentFiles.get().then((files)=>{
console.log(files);
})
Reference Link:
https://pnp.github.io/pnpjs/sp/attachments/
Hope it will helpful to you and if so then Please mark my response as Best Response & Like to help others in this community