cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Michael-netIP
Level: Power Up

Save attachments to SharePoint list item

I have a flow that adds a new item to a SharePoint list. That works fine.

But i also want to take attachments and save them to the item - just as if the user uploaded attachments manually.

The location for manual uploaded attachments are list/thelist/Attachments/<id/....

 

the error is (Response, have exchanged names with < >):

Body

{ "status": 502, "message": "Cannot create folder \"sites/<sitename/Lists/<listname>/Attachments/5\".", "source": "https://<domain>.sharepoint.com/sites/<sitename>/_api/web/folders/add('/sites/<sitename>/Lists/<listname>/Attachments/5')", "errors": [ "-2130247165" ]
6 REPLIES 6
Michael-netIP
Level: Power Up

Re: Save attachments to SharePoint list item

it can save the attachement files to existing folders.

It seems the problem is that if the folder doesn't exist, the it can't create it.

 

eg. my structure is:

/List/myList/Attachments/2 - save files ok

but trying to save to /List/myList/Attachments/5 - fails

Highlighted
caseyFCRT
Level: Powered On

Re: Save attachments to SharePoint list item

I was able to dynamically create folders based upon the subject of the email: New Folder/[Subject]

 

There does appear to be a problem with files over a certain size.  There is another thread about that issue.  The original poster had issues when the file size was greater than 90kb.

Michael-netIP
Level: Power Up

Re: Save attachments to SharePoint list item

How did you create the folder?

 

And is it a folder under the "Attachments" folder?

 

 

I will look into the filesize issue

caseyFCRT
Level: Powered On

Re: Save attachments to SharePoint list item

jzelvy
Level: Powered On

Re: Save attachments to SharePoint list item

I ran into a similar issue.  I initially created a SharePoint 2013 workflow that fired on item creation to create an attachment generating the proper "attachments/[ID]" folder and then deleted the attachment.  This hacked worked for a little bit but it can easily run into timing issues and can be confusing for end users.

 

[Method: Post] Webservice call:  _api/web/lists/GetByTitle('LISTNAME')/items([%Current Item:ID%])/AttachmentFiles/add(FileName='file.txt')

 

[Method: Delete] Webservice call: _api/web/lists/GetByTitle('LISTNAME')/items([%Current Item:ID%])/AttachmentFiles/getByFileName('file.txt')

 

After attempting to add a delay between List Item Creation and Create File attachment, I can no longer get attachments to work.

frdrcjrdn
Level: Powered On

Re: Save attachments to SharePoint list item

Hi everyone,

I've just created my first flow using this template and I have a problem with attachments with the same name : if I already have a file named X.pdf and I received a new email with an attachment named X.pdf, the flow is overwrtiting the first file (I can see it in the versionning of Sharepoint)...

So I would like to add a date/time stamp in the filename but it failed every time when I am adding another field in "file name" than "Name"... Did someone know how to do that ?

 

In fact, I would like to use this flow in order to receive PDF orders and I don't want to miss one order if it has the same name !

 

Thanks

Fred

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Coming Soon: T-shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors
Users online (5,935)