How to pass an array of strings to WCF REST via a DELETE request?

the contract

[OperationContract(IsOneWay = true)] [WebInvoke(Method = "DELETE")] void DeleteFiles(string[] filesPath); 

Call

 public void DeleteFiles(string[] filesPath) { var request = WebRequest.Create("http://localhost:8733/FileServer/DeleteFiles"); request.Method = HttpMethod.Delete.Method; var requestStream = request.GetRequestStream(); var sw = new StreamWriter(requestStream); foreach (var filePath in filesPath) sw.WriteLine(Encoding.UTF8.GetBytes(filePath)); request.GetResponse(); } 

The DeleteFiles(string[] filesPath) is called, but the filesPath = null variable filesPath = null .

For service I use webHttpBinding .

    1 answer 1

    The server expects to see the parameters in the request parameters and not in the body. Delete is not put / post. However, with the transfer of an array in the parameter is not so simple. How to make a call, you can read on enSO .

    • Yes, I saw this post thanks, but I would not like to make so many changes due to one method. I think it is possible to transmit an array of strings via POST request in the form of a Stream, and on the server side, parse the received Stream into an array of strings. - Murad
    • @ Murad is possible. Remember to just change the web method. - andreycha