How to get URL of the attachment from a list item

Hi @UiPath_Community,

I am looking for ways to extract URL of an attachment for a SharePoint list item.

I am using Get List Items activity from Microsoft Office365 package which only returns me the value of Attachment column as ‘true’ or ‘false’.

My requirement is to download that attachment.

Any ideas on how to fetch the URL?

Regards
Sonali

Hi @sonaliaggarwal47 ,

Use “Get List Items” Activity

Retrieve the items from the SharePoint List.

Store the ID of the list item that has attachments.

  1. Use “Send HTTP Request” Activity (or MS Graph API if needed)

Make an API call to fetch attachment details for a specific list item.

The URL format for SharePoint REST API:

https:///_api/web/lists/getbytitle(‘’)/items()/AttachmentFiles

Headers Required:

Accept: application/json;odata=verbose

Authorization: Bearer (if needed)

  1. Extract Attachment URLs

The API response will return a list of attachments with their URLs.

Parse the JSON response to extract the ServerRelativeUrl or AbsoluteUrl.

  1. Use “Download File” Activity

Use the extracted URL to download the attachment and save it locally.

Regards,
Arivu

While exporting the list to Excel - Does the attachment URL is coming or not??

if it is available in excel - you can get the URL from there as well by coding

Hi @sharazkm32,

I don’t think that will happen.

I have checked and logged the values of datatable, its coming as true/false. so even if i write this datatable to excel, values that I see in datatable will only get printed.

Regards
Sonali

Hi @arivu96,

I can try this and see if it works.

Regards
Sonali

I meant to export manually the SharePoint list to Excel and check the output coming in Excel

@sharazkm32,

Thanks for that idea.

I tried to export in excel, Attachments column didn’t even show up in excel.

Then I tried to export in csv, Attachments column showed up but with values 1 or 0.

Regards
Sonali

Is this SharePoint online or on premise ?

@sharazkm32,

its online.

Regards
Sonali

Hi @arivu96 @sharazkm32,

Thanks you for your help on this issue.

Due to O365 limitation - it can’t fetch attachment URLs from sharepoint list items, so we ended up trying below solutions:

  1. Fetch attachments details from sharepoint list via http request as suggested by @arivu96. This step should work but didn’t work in our case due to access issues, seems like app id and secret had some restrictions which we have not been able to resolve yet.

  2. So, we created a power automate flow to fetch attachment details. Call that PA flow using http request from UiPath and collect the response. This worked like a charm!

Hope this helps someone struggling with this issue.

Regards
Sonali

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.