I am trying to do a POST like this:
HttpClient hc = new HttpClient();
byte[] bytes = ReadFile(@"my_path");
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("FileName", "001.jpeg"));
postData.Add(new KeyValuePair<string, string>("ConvertToExtension", ".pdf"));
postData.Add(new KeyValuePair<string, string>("Content", Convert.ToBase64String(bytes)));
HttpContent content = new FormUrlEncodedContent(postData);
hc.PostAsync("url", content).ContinueWith((postTask) => {
postTask.Result.EnsureSuccessStatusCode();
});
but I receive this exception:
Invalid URI: The Uri string is too long.
complaining about this line: HttpContent content = new FormUrlEncodedContent(postData);
. For small files it works but I don't understand why for larger ones it doesn't?
When I do POST the content can be larger...Then why it complains about URI?