I have a C# .Net console app performing an ftp copy runs from the cmd command prompt, but when run from a SQL agent job or from SQL server management studio, the FTP part of the app fails:
declare @cmd varchar(200)
select @cmd = 'c:\ftptest\test.exe';
exec master..xp_cmdshell @cmd ;
The console application when run from command prompt does the FTP file upload but throws an exception when using the SQL route:
System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.FtpWebRequest.GetResponse()
This sounds like a permissions problem but the same user is running the console app in both the SQL Server Management Studio query and from the command prompt and both are running on the same server.