Question

I have tried to upload a file asynchronously with RestSharp. Unfortunately I can't get it to work. If I use client.Execute() instead of client.ExecuteAsync() it works.

Why? Is it a Bug? Is it a missing feature? Is it my fault?

Here is my code:

string file = "c:\\file.zip";

var request = new RestRequest(Method.POST);
request.AddFile(Path.GetFileName(file), Path.GetFullPath(file));
// Params ...

var client = new RestClient();
client.BaseUrl = url;

// Fails with sth. like TimedOut????
client.ExecuteAsync(request, response => {});
// Works
var response = client.Execute(request);
Was it helpful?

Solution

After a while I find out that AddFile (string name, string path) and AddFile (string name, string path) fails while AddFile (string name, Action writer, string fileName) works with ExecuteAsync().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top