I am using tableau server for reporting in my application for reporting and I have created report files at tableau server, which is working fine. I have requirement to send these report file over the mail to user. I have exported report into byte [] using following code
var client = new RestSharp.RestClient(repartPath);
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Connection", "keep-alive");
request.AddHeader("Accept-Encoding", "gzip, deflate");
request.AddHeader("Host", hostname);
request.AddHeader("Postman-Token", tokenValue);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "*/*");
request.AddHeader("User-Agent", "PostmanRuntime/7.19.0");
request.AddHeader("X-Tableau-Auth", tableauToken);
IRestResponse response = client.Execute(request);
if (response.IsSuccessful)
{
return response.RawBytes;
}
Above code is returning byte []. Now I want to covert byte [] into data table, to convert byte [] into data table.I am using below code:
using (MemoryStream stream = new MemoryStream(byteArrayData))
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
_dataTable= (DataTable)binaryFormatter.Deserialize(stream);
}
But it is throws exception: input string not in valid binary format. Any help will be appreciated, many thanks in advance .