Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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/
AGNL

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()