Forum Discussion
How to access SharePoint Lists Attachment in Fabric
- 2 years ago
I see. If I understand correctly, you basically just want to store a copy of the files somewhere.
I guess you can use Notebook or Data Pipeline to copy the files into a files folder in a Lakehouse.
Or you could create a folder for each list item, and insert the files which are attached to each list item. (automatically).
I don't know the code for doing that, and unfortunately I don't have the time to test that now, but it sounds like something which is doable.
---
It seems maybe you will need to create an app registration (service principal) in Azure and give this service principal access to the Sharepoint list, and then use the service principal to authenticate to the Sharepoint list attachments from either a Notebook or Data pipeline.
Perhaps this documentation will help:
Working with folders and files with REST | Microsoft Learn
I am guessing use GET method to get each attachment file from Sharepoint via API, and then have the Notebook or Data pipeline save the file in a folder in Fabric Lakehouse.
---
If a low code approach is preferred, I am thinking maybe Power Automate could be an alternative way of extracting the attachments from the list:
How to store all attachments from a SharePoint list to one folder? - Microsoft Q&A
But per my knowledge there are no Fabric connectors in Power Automate. So if the aim is to store the files in Fabric, I think it would need to use some API: Solved: Automate file movement lakehouse > onderive - Microsoft Fabric Community
If going ahead with Power Automate, maybe the easiest is to just store the attachment files in another folder in Sharepoint which is "visible" in the Sharepoint document hierarchy (as opposed to the list attachments folders, which seem to be "hidden" in Sharepoint).
Thanks for the response!
I was able to read the file by manually providing the serverrelativeurl using web api.
But now the real challenge is, how I can automate this? I mean there will a lot of files within each list items, I can't copy url for each attachment repeatedly, Is there any way around to solve this?
(I want to keep all the files seperately)
If you want to keep the files separately, and the number of attachments may increase dynamically, I think you will need to use Data pipeline or Notebook, in order to loop through the dynamic list of attachments. (if the number of attachments may increase over time, and you want the attachments to be kept separately, I don't think Dataflow Gen2 can handle that).
We can find the dynamic list of attachments by using the SharePoint Online List connector which we have already used before.
The next step is to loop through the list of attachments and get the contents of each file and store as a file copy or as a table in the Lakehouse.
Unfortunately I don't have the time to test it now.
Will the contents of the attachments have the same layout in each file (same column names, same worksheet name inside the workbook, etc.)?
Or will each file have different layout inside the file?
- frithjof_v2 years ago
Community Champion
I see. If I understand correctly, you basically just want to store a copy of the files somewhere.
I guess you can use Notebook or Data Pipeline to copy the files into a files folder in a Lakehouse.
Or you could create a folder for each list item, and insert the files which are attached to each list item. (automatically).
I don't know the code for doing that, and unfortunately I don't have the time to test that now, but it sounds like something which is doable.
---
It seems maybe you will need to create an app registration (service principal) in Azure and give this service principal access to the Sharepoint list, and then use the service principal to authenticate to the Sharepoint list attachments from either a Notebook or Data pipeline.
Perhaps this documentation will help:
Working with folders and files with REST | Microsoft Learn
I am guessing use GET method to get each attachment file from Sharepoint via API, and then have the Notebook or Data pipeline save the file in a folder in Fabric Lakehouse.
---
If a low code approach is preferred, I am thinking maybe Power Automate could be an alternative way of extracting the attachments from the list:
How to store all attachments from a SharePoint list to one folder? - Microsoft Q&A
But per my knowledge there are no Fabric connectors in Power Automate. So if the aim is to store the files in Fabric, I think it would need to use some API: Solved: Automate file movement lakehouse > onderive - Microsoft Fabric Community
If going ahead with Power Automate, maybe the easiest is to just store the attachment files in another folder in Sharepoint which is "visible" in the Sharepoint document hierarchy (as opposed to the list attachments folders, which seem to be "hidden" in Sharepoint).
- aiwithchirag2 years agoFrequent Visitor
Thanks Again for clarifying and responding back!
The File content may change, the columns name may change, it's basically not fixed.
In a list like 'Financials', I can have some financial reports let's say which needs to be approved or something like that, but can have other files too so this format is not fixed, the basic idea is to fetch all the files attached within each list items and store it seperately somewhere.
To Answer your question, yes it will have different layout sometimes and sometimes it can be same.