cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
paul_culmsee
Level 8

SharePoint copy file action falsely reports 404 missing file

Hiya

 

I was running a training class yesterday and tthe class hit this issue. Here is how to repro:

 

Firstly, I used the SharePoint copy file action with the following config:

 

Trigger: "When a file is created or modified (properties only)"

 

Sarahissue1.png

 

Source doclib: "/Sarahs QAP docs"

Destination doclib: "/QAP Docs Published"

 

The copy action currently looks as follows: As you can see I pull the file name from the trigger and note that I have removed the leading slash from the destination File Path. Also note that right now I have hard-coded the destination file name to test.docx.

 

SarahIssue2.png

So now I ensure that in the destination library that test.docx does not exist.

 

sarahissue3.PNG

 

As you can see the library is emtpy. So I edit the properties of a document in the source library to trigger the flow, and it works ok...

 

Sarahissue4.jpg

Now watch what happens when I do it again..... I edit the properties on the same soiurce file to trigger a second flow run...

 

sarahissue5.PNG

The error can be seen in the message above, but it is subtle... Of course, we know the document does exist because the first iteration placed it there. Taking a closer look, I see the web service call causing the fault...

 

"source": "https://mytenant.sharepoint.com/sites/PAAuckland/_api/web/GetFileByServerRelativePath(decodedUrl=@p)...'"

 

I paste this web service call into a browser and confirm the same error that the file in the above path does not exist.

 

sarahissue6.PNG

 

But take a look at the URL in the message above... see the extra slash?  I confirmed this by decoding the URL. You can see an extra encoded slash still there...

 

mytenant.sharepoint.com/sites/PAAuckland/_api/web/GetFileByServerRelativePath(decodedUrl=@p)/Etag?@p='/sites/PAAuckland/%2fQAP+Docs+Published%2ftest.docx'

 

If I remove this slash and hit the URL manually I get a positve result... eg:

 

sarahissue7.PNG

Essentially until this issue is fixed, the copy file action for SharePoint is broken...

 

regards

 

Paul

5 REPLIES 5
gokello
Level 8

Re: SharePoint copy file action falsely reports 404 missing file

Worked on a similar MS Flow.

Flow Logic:  

  1. When new item is created in a list, copy doc from source document library to target document library.
  2. Use New name at target library.

Work perfectly except if target has a document with the same name.  i.e. if document already exists at target.

 

MS flow has an Overwrite Flag - presumably to allow for replacing existing documents (at the target).

This however doesn't work. MS Flow fails consistently whenever document exists at the target.

 

 

Error Message:

CopyFileFails Message.jpg

--------------

------------CopyFileFails.jpg

 

 

spg-john-liu
Level 8

Re: SharePoint copy file action falsely reports 404 missing file

This is quite possibly related to sharepoint's ServerRelativeUrl returning / on the rootweb, but without a trailing slash on subwebs.

AnotherMSprofil
Level: Powered On

Re: SharePoint copy file action falsely reports 404 missing file

I confirm that this is not fixed yet.

This is very annoying, since the only other reliable way is to use Get File Contents followed by Create File.

But this means 2xFileSize data transfers each time. Combined with 50MB limit, this is not a solution!

 

Ozmoeciz
Level: Powered On

Re: SharePoint copy file action falsely reports 404 missing file

First let's confirm the file path (Web Address) of the document library using the library settings. Confirm File Path in Document Library Settings.PNG

 

 

As you can see, it is possible to have a different Quick Launch link and Library name than the actual Library path (Web Address). I've seen site owners have similar issues and it's usually the incorrect document library path, file name or syntax. The file name is required with this action; having the path alone will also return a similar failure summary.

 

Looking at your flow, I see that in the Source File Path of the Sharepoint Copy file action you are adding '.docx' after the 'Name' dynamic content. Remove the 'docx' and 'Name dynamic content. If you want to include the file extension, use the 'File name with extension' dynamic content. i.e /Sarahs QAP docs/'File name with extension'

 

Secondly, the Destination Soure path should have similar dynamic content as the source file path. Try using /QAP Docs Published/'File name with extension'

This is assuming both paths are the same as the Web Address listed in the document library settings. An example of an presumed path is below:

 

Assumed Path.PNG

 

Failure Summary of assumed path.PNG

 

 

 

Here's a successful overview of my example Publication Process flow:

 

Overall Flow.PNG

 

Details on changed action properties to make a successful flow:

 

Copy Success Example.PNG

 

Move Process Details based on approvers response.PNG

 Hope this helps. Smiley Happy

 

 

 

Highlighted
bresleveloper
Level: Power Up

Re: SharePoint copy file action falsely reports 404 missing file

Using "When file is created or modified in a folder" event trigger after duplicating the file solved the problem

 https://bresleveloper.blogspot.com/2018/12/microsoft-flow-form-into-excel-create.html

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,827)