Remote Sheet API encoding problem
Hi!
I´m trying to post a sheet through the remote api and I´m having some inconveniences with encoding.
Currently I send my files like this and works...
c#
StringBuilder contents = new StringBuilder();
//boundary
contents.AppendLine(header);
contents.AppendLine(string.Format("Content-Disposition: form-data; name=\"content\"; filename=\"{0}\"", fileName));
contents.AppendLine("Content-Type: application/vnd.ms-excel");
contents.AppendLine();
contents.AppendLine(Encoding.Default.GetString(file));
//boundary
contents.AppendLine(header);
//saveurl
contents.AppendLine("Content-Disposition: form-data; name=\"saveurl\"");
contents.AppendLine();
contents.AppendLine("
http://www.some.com
");
//boundary
contents.AppendLine(header);
//id
contents.AppendLine("Content-Disposition: form-data; name=\"id\"");
contents.AppendLine();
contents.AppendLine("adfwedf");
//boundary
contents.AppendLine(header);
//format
contents.AppendLine("Content-Disposition: form-data; name=\"format\"");
contents.AppendLine();
contents.AppendLine("xls");
//footer
contents.AppendLine(footer);
byte[] bytes = Encoding.Default.GetBytes(contents.ToString());
request.ContentLength = bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Flush();
requestStream.Close();
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string responseBody = reader.ReadToEnd();
reader.Close();
However, If I use UTF8 (byte[] bytes = Encoding.UTF8.GetBytes) instead of the deafult encoding I receive a "500 internal server error".
Any thoughts?
Thanks in advance,
Gonzalo.