Share via


The remote server returned an error: (501) Syntax error in parameters or arguments

Question

Tuesday, June 30, 2015 7:24 AM

Hi!!

I have the following program that I would have to rename an XML file from an FTP server, but does not make me anything, I get the following error

"The remote server returned an error: (501) Syntax error in parameter or arguments"

when I remove the en WebRequestMethods.Ftp.Rename, I do not get errors in the program but do not rename the XML file

My program is this:

FtpWebRequest`` dirFTP2 ``=`` `` ``((``FtpWebRequest``)``FtpWebRequest``.``Create``(``"ftp://10.160.190.260/FI_SINC_SVPP_A40986_20150513002939.XML;1"``));
        ``NetworkCredential`` cr ``=`` ``new`` ``NetworkCredential``(``textBox2``.``Text``,`` textBox2``.``Text``);
        dirFTP2``.``Credentials`` ``=`` cr``;

        textBox10``.``Text`` ``=`` ``"/FI_SINC_SVPP_A40986_20150513002939.XML_OLD"``);

        dirFTP2``.``Method`` ``=`` ``WebRequestMethods``.``Ftp``.``Rename``;
        dirFTP2``.``RenameTo`` ``=`` textBox10``.``Text``;

Then the details of the exception are:

No`` se control``ó`` ``System``.``Net``.``WebException
Message``=``The`` remote server returned an error``:`` ``(``501``)`` ``Syntax`` error ``in`` parameters or arguments``.
Source``=``System
StackTrace``:
   at ``System``.``Net``.``FtpWebRequest``.``SyncRequestCallback``(``Object`` obj``)
   at ``System``.``Net``.``FtpWebRequest``.``RequestCallback``(``Object`` obj``)
   at ``System``.``Net``.``CommandStream``.``Dispose``(``Boolean`` disposing``)
   at ``System``.``IO``.``Stream``.``Close``()
   at ``System``.``IO``.``Stream``.``Dispose``()
   at ``System``.``Net``.``ConnectionPool``.``Destroy``(``PooledStream`` pooledStream``)
   at ``System``.``Net``.``ConnectionPool``.``PutConnection``(``PooledStream`` pooledStream``,`` ``Object`` owningObject``,`` ``Int32`` creationTimeout``,`` ``Boolean`` canReuse``)
   at ``System``.``Net``.``FtpWebRequest``.``FinishRequestStage``(``RequestStage`` stage``)
   at ``System``.``Net``.``FtpWebRequest``.``GetResponse``()
   at ``WindowsFormsApplication1``.``Form1``..``ctor``()`` ``in`` C``:``\Documents and ``Settings``\SAM844\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\Form1``.``cs``:``line ``43
   at ``WindowsFormsApplication1``.``Program``.``Main``()`` ``in`` C``:``\Documents and ``Settings``\SAM844\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\Program``.``cs``:``line ``18
   at ``System``.``AppDomain``.``_nExecuteAssembly``(``RuntimeAssembly`` assembly``,`` ``String``[]`` args``)
   at ``System``.``AppDomain``.``ExecuteAssembly``(``String`` assemblyFile``,`` ``Evidence`` assemblySecurity``,`` `` ``String``[]`` args``)
   at ``Microsoft``.``VisualStudio``.``HostingProcess``.``HostProc``.``RunUsersAssembly``()
   at ``System``.``Threading``.``ThreadHelper``.``ThreadStart_Context``(``Object`` state``)
   at ``System``.``Threading``.``ExecutionContext``.``Run``(``ExecutionContext`` executionContext``,`` ``ContextCallback`` callback``,`` `` ``Object`` state``,`` ``Boolean`` ignoreSyncCtx``)
   at ``System``.``Threading``.``ExecutionContext``.``Run``(``ExecutionContext`` executionContext``,`` ``ContextCallback`` callback``,`` `` ``Object`` state``)
   at ``System``.``Threading``.``ThreadHelper``.``ThreadStart``()
InnerException``:``

As I have seen online the failure is in the configuration of the parameters, the thing is not like I have to set up, anyone know ?????

Thank you very much for everything.

A greeting!

All replies (3)

Tuesday, June 30, 2015 8:56 AM ✅Answered

If that is HTTP Error code 501, that one means:

"501 Not Implemented
The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API)."

Based on your specific exception I would say you guessed the signature of the function wrong. So now the server has no idea wich function you mean.
It could also be that you don't anotate/formated the types properly, so what you think is a string is an int or vice-versa for the other side.

It all depends on the documentation of the other end of that FTP-Request.


Tuesday, June 30, 2015 8:57 AM

Woah that is nice :)


Tuesday, June 30, 2015 9:20 AM

I believe that this profile is just having fun on these forums, below is the same same question with the same silly replies to the contributors reply:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/1ccece7c-3af6-4711-b051-597478f95321/renameto-a-file-in-a-ftp-server?forum=csharpgeneral

So please tell us your story are you on FB or twitter here?!!

Contributors are using their time to investigate your question and you're maximizing your silly replies!

Fouad Roumieh