Getting Exception Calling "Get Response" with 0 arguments "this remote server returned an error"

Advertisement

AGNL
Joined:
Posts:
1
Location:
USA

Getting Exception Calling "Get Response" with 0 arguments "this remote server returned an error"

Getting error message when I try to connect to this ftp. Strangely enough, it works when I log in with a different user account for the ftp but this one with correct credentials does not work...
Exception calling "GetResponse" with "0" argument(s): "The remote server 
returned an error: (503) Bad sequence of commands."
At line:16 char:9
+         $response = $request.GetResponse()
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException
 
You cannot call a method on a null-valued expression.
At line:17 char:9
+         $reader = New-Object IO.StreamReader $response.GetResponseStr ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull


$Date = Get-Date -format MM-dd-yyyy
$ftp = "ftp://ftp.makethiswork.com/"
$user = 'me'
$pass = 'help'
$folder = '/yes'
$target = "C:\Users\g\Desktop\VS Projects\Powershell\FTPDL\"

#SET CREDENTIALS
$credentials = new-object System.Net.NetworkCredential($user, $pass)

function Get-FtpDir ($url,$credentials) {
$request = [Net.WebRequest]::Create($url)
$request.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory
if ($credentials) { $request.Credentials = $credentials }
$response = $request.GetResponse()
$reader = New-Object IO.StreamReader $response.GetResponseStream()
while(-not $reader.EndOfStream) {
$reader.ReadLine()
}
#$reader.ReadToEnd()
$reader.Close()
$response.Close()

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
31,935
Location:
Prague, Czechia

Re: Getting Exception Calling "Get Response" with 0 arguments "this remote server returned an error"

This is a support forum for WinSCP.
Your question does not seem to be related to WinSCP anyhow.
Please move it to an appropriate site, like https://stackoverflow.com/

Reply with quote

Advertisement

You can post new topics in this forum