Can RestSharp send a List<string> in a POST request?
It depends on what server you're hitting, but if you're hitting an ASP.NET Web API controller (and probably other server-side technologies), it'll work if you add each item in the collection in a loop:
foreach (var child in test.Children) request.AddParameter("children", x));
Use AddJsonBody
var client = new RestClient();var request = new RestRequest("http://localhost", Method.PUT);request.AddJsonBody(new TestObj { Name = "Fred", Children = new List<string> {"Arthur", "Betty"}});client.Execute(request);
Api Side
[AcceptVerbs("PUT")]string Portefeuille(TestObj obj){ return String.Format("Sup' {0}, you have {1} nice children", obj.Name, obj.Children.Count());}
I had a similar problem with a list of Guids. My post would work but the list would never have the correct data. I hacked it abit and used the json.net to serialize the object
Issue I had on another stackoverflow post
I know this isn't perfect but does the trick