Issue putting file to webdav location

Advertisement

gk87
Joined:
Posts:
3

Issue putting file to webdav location

Hi there,

I'm lost with the following code for putting a file on a webdav location named https://webdav.domain.com/subdirectory/ and I'm hoping someone can point me to the solution.

The $session.output output is:
winscp> option batch on
batch on
reconnecttime 120
winscp> option confirm off
confirm off
winscp> option reconnecttime 120
reconnecttime 120
winscp> open "dav://account:***@webdav.domain.com%2F:443" -timeout=15
Connecting to host...
Authenticated.
Starting the session...
Session started.
Active session: [1] account@webdav.domain.com/
winscp> pwd
/:443

The error returned for the putfiles is:

Exception calling "Check" with "0" argument(s): "Error transferring file 'C:\uploadtest.csv'. 404 Not Found"

The code:

Add-Type -Path ".\WinSCP-5.13-Automation\WinSCPnet.dll"

# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
      Protocol = [WinSCP.Protocol]::Webdav
      HostName = "webdav.domain.com/"
      PortNumber = "443"
      UserName = "account"
      Password = "P@ssw0rd"
    }
 
$session = New-Object WinSCP.Session
# Connect
$session.Open($sessionOptions)

# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Automatic
       
#$transferResult =

$session.PutFiles("C:\uploadtest.csv", "subdirectory/uploadtest.csv", $False, $transferOptions)
$session.PutFiles("C:\uploadtest.csv", "/subdirectory/uploadtest.csv", $False, $transferOptions)
$session.PutFiles("C:\uploadtest.csv", "./subdirectory/uploadtest.csv", $False, $transferOptions)
$session.PutFiles("C:\uploadtest.csv", "./uploadtest.csv", $False, $transferOptions)
$session.PutFiles("C:\uploadtest.csv", "/uploadtest.csv", $False, $transferOptions)
$session.PutFiles("C:\uploadtest.csv", "./uploadtest.csv", $False, $transferOptions)

# Throw on any error
# $transferResult.Check()

I hope someone can help me.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: Issue putting file to webdav location

For a start, remove the slash from HostName and set WebdavSecure instead of setting PortNumber to 443.

If that does not help, please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

gk87
Joined:
Posts:
3

Hi Martin,

Thanks for the reply. Find attached the logfiles for both the opening post config and the new config as you suggested. It appears that when using your config opening the session hangs / gets in some sort of loop. No connection can be established.

    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
      Protocol = [WinSCP.Protocol]::Webdav
      HostName = "webdav.domain.com"
      WebdavSecure = $True
      UserName = "account"
      Password = "P@ssw0rd"
    }
  • log_oldconfig.txt (28.22 KB, Private file)
  • log_newconfig.txt (1.36 MB, Private file)

Reply with quote

gk87
Joined:
Posts:
3

martin wrote:

Can you connect to that WebDAV server using any WebDAV client?

I tried WinSCP and BitKinex but I'm not able to connect. The only working option is Windows Explorer (Add a network location). I also asked the webdav URL provider to clarify on this.

Reply with quote

Advertisement

You can post new topics in this forum