Unable to overwrite file using WinSCP dll with WebDAV

Advertisement

T.Hylander
Joined:
Posts:
4

Unable to overwrite file using WinSCP dll with WebDAV

Hi,
Trying to upload and overwrite a file on our server over WebDAV protocol, but just getting a "500 internal server error"-message. Doing the same on the WinSCP GUI works like it should.
Uploading a new file works like a charm as well. Credentials on server is double-checked.
Generated script from client, and just used the example from website, with the addition by adding transferOptions.OverwriteMode = OverwriteMode.Overwrite.
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Webdav,
    HostName = "www.domain.se",
    UserName = "User",
    Password = "Password",
    WebdavSecure = true,
    TlsHostCertificateFingerprint = "00:00:00:00:00:00:00:00:00:00:00",
 
};
using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);
 
    // Upload files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
    transferOptions.OverwriteMode = OverwriteMode.Overwrite;
 
    TransferOperationResult transferResult;
    transferResult =
        session.PutFiles(@"C:\temp\test.json", "/webdav/files/test/", false, transferOptions);
    // Throw on any error
    transferResult.Check();
 
    // Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
        MessageBox.Show("Upload of " + transfer.FileName + " succeded");
    }
}
The complete error-message:
WinSCP.SessionRemoteException: Error transferring file 'c:\temp\test.json'
500 Internal Server Error
at WinSCP.OperationResultBaseCheck()
at ProgramFormProgram.button2_Click(Object sender, EventArgs e) in c:\temp\Program\Form1.cs::row 220
I also tried using Session.PutFileToDirectory but that didn't change anything.

Does anyone have some hints on what I should look for?
Thanks!

Reply with quote

Advertisement

T.Hylander
Joined:
Posts:
4

Client log attached as private file.

Also tried session.RemoveMile([file]) but that throw the same error.
  • WinSCP_uploaderrorlog.log (34.41 KB, Private file)

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum