Note that there are some explanatory texts on larger screens.

plurals
  1. POSharepoint problem saving a file over an existing file in a document library
    primarykey
    data
    text
    <p>I have an existing document in a document library and I'm trying to overwrite that file in code using code like this:</p> <pre><code>byte[] data = ... SPListItem li = ... li.File.SaveBinary(data); </code></pre> <p>When I run this code I get:</p> <pre><code>Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---&gt; System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. at Microsoft.SharePoint.Library.SPRequestInternalClass.PutFile(String bstrUrl, String bstrWebRelativeUrl, Object varFile, PutFileOpt PutFileOpt, String bstrCreatedBy, String bstrModifiedBy, Int32 iCreatedByID, Int32 iModifiedByID, Object varTimeCreated, Object varTimeLastModified, Object varProperties, String bstrCheckinComment, UInt32&amp; pdwVirusCheckStatus, String&amp; pVirusCheckMessage) at Microsoft.SharePoint.Library.SPRequest.PutFile(String bstrUrl, String bstrWebRelativeUrl, Object varFile, PutFileOpt PutFileOpt, String bstrCreatedBy, String bstrModifiedBy, Int32 iCreatedByID, Int32 iModifiedByID, Object varTimeCreated, Object varTimeLastModified, Object varProperties, String bstrCheckinComment, UInt32&amp; pdwVirusCheckStatus, String&amp; pVirusCheckMessage) --- End of inner exception stack trace --- at Microsoft.SharePoint.Library.SPRequest.PutFile(String bstrUrl, String bstrWebRelativeUrl, Object varFile, PutFileOpt PutFileOpt, String bstrCreatedBy, String bstrModifiedBy, Int32 iCreatedByID, Int32 iModifiedByID, Object varTimeCreated, Object varTimeLastModified, Object varProperties, String bstrCheckinComment, UInt32&amp; pdwVirusCheckStatus, String&amp; pVirusCheckMessage) at Microsoft.SharePoint.SPFile.SaveBinary(Byte[] file, String checkInComment, Boolean checkRequiredFields, Boolean bIsMigrate, Boolean bIsPublish, SPUser modifiedBy, DateTime timeLastModified, SPVirusCheckStatus&amp; virusCheckStatus, String&amp; virusCheckMessage) at Microsoft.SharePoint.SPFile.SaveBinary(Byte[] file, Boolean checkRequiredFields, Boolean bIsMigrate, Boolean bIsPublish, SPUser modifiedBy, DateTime timeLastModified) at Microsoft.SharePoint.SPFile.SaveBinary(Byte[] file, Boolean checkRequiredFields) at Microsoft.SharePoint.SPFile.SaveBinary(Byte[] file) at TestClass.UploadFile() </code></pre> <p>I'm running this code on a form hosted in the same site as sharepoint and the user that is running the code can upload the file manually just fine. Do I need to delete the file first? Check it out?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload