call to AddTemplateFile failing with FileNotFoundException when attempting to restore an aspx file

%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%3CMESSAGE%20lang%3D%22%26lt%3B%2FSPAN%22%3E%3CSPAN%3E%22en-US%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3BFile%20Not%20Found.%3C%2FSPAN%3E%3C%2FMESSAGE%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CEM%3EPossible%20Reasons%20that%20I%20can%20think%20of%3A%3C%2FEM%3E%3C%2FDIV%3E%3CUL%3E%3CLI%3E%3CSPAN%3EThe%20parameter%2C%20templateFileType%20is%20not%20correct%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EThe%20file%20being%20restored%20is%20not%20a%20ghosted%20file.%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EAny%20ideas%20as%20to%20why%20the%26nbsp%3B%3CSPAN%3EFileNotFoundException%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThanks%26nbsp%3B%3C%2FDIV%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1454011%22%20slang%3D%22en-US%22%3Ecall%20to%20AddTemplateFile%20failing%20with%20FileNotFoundException%20when%20attempting%20to%20restore%20an%20aspx%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1454011%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20using%20the%20Sharepoint%20API%26nbsp%3BSP.FileCollection.addTemplateFile%20Method%20to%20restore%20pages%20that%20have%20been%20backed%20up%20previously.%26nbsp%3B%20Occasionally%2C%20this%20fails%20and%20returns%20a%20FileNotFoundException.%26nbsp%3B%20I've%20been%20trying%20to%20track%20down%20what%20this%20error%20is%20pointing%20towards.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EHere%20is%20the%20request%3A%3C%2FEM%3E%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fzzzzyyyyy.com%2Fsites%2FITArchTest%2F_api%2Fweb%2FLists(guid'769e813d-c666-4a75-9d27-acd5ddb04585')%2FRootFolder%2FFiles%2FAddTemplateFile(urlOfFile%3D'%2Fsites%2FITArchTest%2FSitePages%2F%25202020-06-05%252002%3B37%3B26%2520afadfadf.aspx'%2C%2520templateFileType%3D1)%3F%24expand%3DListItemAllFields%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fzzzzyyyyy.com%2Fsites%2FITArchTest%2F_api%2Fweb%2FLists(guid'769e813d-c666-4a75-9d27-acd5ddb04585')%2FRootFolder%2FFiles%2FAddTemplateFile(urlOfFile%3D'%2Fsites%2FITArchTest%2FSitePages%2F%25202020-06-05%252002%3B37%3B26%2520afadfadf.aspx'%2C%2520templateFileType%3D1)%3F%24expand%3DListItemAllFields%3C%2FA%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%3CEM%3EAnd%20the%20response%3A%3C%2FEM%3E%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3E%221.0%22%3C%2FSPAN%3E%3CSPAN%3E%20encoding%3D%3C%2FSPAN%3E%3CSPAN%3E%22utf-8%22%3C%2FSPAN%3E%3CSPAN%3E%3F%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CERROR%20m%3D%22%26lt%3B%2FSPAN%22%3E%3CSPAN%3E%22%3CA%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fado%2F2007%2F08%2Fdataservices%2Fmetadata%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fschemas.microsoft.com%2Fado%2F2007%2F08%2Fdataservices%2Fmetadata%3C%2FA%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FERROR%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%3CCODE%3E-%3C%2FCODE%3E%3C%2FSPAN%3E%3CSPAN%3E2147024894%3C%2FSPAN%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CSPAN%3ESystem.IO.FileNotFoundException%3C%2FSPAN%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%3CMESSAGE%20lang%3D%22%26lt%3B%2FSPAN%22%3E%3CSPAN%3E%22en-US%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3BFile%20Not%20Found.%3C%2FSPAN%3E%3C%2FMESSAGE%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CEM%3EPossible%20Reasons%20that%20I%20can%20think%20of%3A%3C%2FEM%3E%3C%2FDIV%3E%3CUL%3E%3CLI%3E%3CSPAN%3EThe%20site%20page%20collection%20does%20not%20exist.%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EThe%20parameter%2C%20templateFileType%20is%20not%20correct%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EThe%20file%20being%20restored%20is%20not%20a%20ghosted%20file.%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EAny%20ideas%20as%20to%20why%20the%26nbsp%3B%3CSPAN%3EFileNotFoundException%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThanks%26nbsp%3B%3C%2FDIV%3E
Highlighted
Regular Visitor

We are using the Sharepoint API SP.FileCollection.addTemplateFile Method to restore pages that have been backed up previously.  Occasionally, this fails and returns a FileNotFoundException.  I've been trying to track down what this error is pointing towards.

 

Here is the request:

And the response:

<?xml version="1.0" encoding="utf-8"?>
    <m:code>-2147024894, System.IO.FileNotFoundException</m:code>
    <m:message xml:lang="en-US">File Not Found.</m:message>
</m:error>
 
Possible Reasons that I can think of:
  • The site page collection does not exist.
  • The parameter, templateFileType is not correct
  • The file being restored is not a ghosted file.
 
Any ideas as to why the FileNotFoundException?
 
Thanks 
0 Replies