I am trying to do a POST as follows:
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 get this exception:
Invalid URI: Uri string is too long.
complaining about this line: HttpContent content = new FormUrlEncodedContent(postData);. For small files, this works, but I donβt understand why for larger files not?
When I do a POST, there may be more content ... Then why is it complaining about a URI?
source
share