Topic "Webdav script 405 Method Not Allowed"

Author Message
StewieGriffin

Guest


When used over GUI everything works fine. When you open an already existing Session in a batch script everything works fine.

But when you generate your session code to do a batch or powershell script the "405 Method not allowed" error is shown.

Here is a working example:

Code:
option batch on
option confirm off
open CloudSession
lcd test
cd test
get *.*
close
exit


When i connect to the session via gui and generate a session code it looks like this:

Code:
open davs://user:password@cloud.xxxxxx.com/


When connecting with winscp.com:

Code:
winscp> open davs://user:password@cloud.xxxxxx.com/
Verbinde mit entferntem Rechner...
405 Method Not Allowed
Verbindung fehlgeschlagen.
winscp>


Same error on this Powershell code:

Code:
# WinSCP .NET assembly laden
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"

# Sitzungsoptionen konfigurieren
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Webdav
    HostName = "cloud.xxxxxx.com"
    PortNumber = 443
    UserName = "user"
    Password = "password"
    WebdavSecure = $True
    TlsHostCertificateFingerprint = "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
}

$session = New-Object WinSCP.Session

Ausnahme beim Aufrufen von "Open" mit 1 Argument(en): "405 Method Not Allowed Verbindung fehlgeschlagen."


Any ideas what could be wrong here?
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
Maybe the root server folder does not implement WebDAV. Maybe you need to start in some subfolder.

For that use SessionOptions.WebdavRoot:
https://winscp.net/eng/docs/library_sessionoptions#webdavroot
Guest




Hi Martin,

you were absolutely right.

By adding

Code:
WebdavRoot = "/remote.php/webdav"


to the Powershell script or adding the root folder to the batch code:

Code:
open davs://user:password@cloud.xxxxxx.com/remote.php/webdav


winscp successfully connects to WebDav Service.

Thank you for your quick help Very Happy
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License