I am trying to use the report service to return a pdf file but I am getting blank files through the Swagger UI and from code. When I force the Api to launch visual studio and step the code through until the file is produced in the temp directory, Crystal is writing the file correctly but the file returned from ServiceStack is blank from code and SwaggerUI, see the code call below, any ideas?
- Code: Select all
ReportsPDFGETRequest pdfreq = new ReportsPDFGETRequest();
pdfreq.ReportID = "a78c84d7-ebb6-4ff9-8974-e0f9c3680094";
pdfreq.ReportParameters = new List<ReportParameter>();
pdfreq.AsAttachment = true;
pdfreq.ReportParameters.Add(new ReportParameter() { Name = "Pass_SP_StartingDebtorAccountNo", Value = "CHRI"});
pdfreq.ReportParameters.Add(new ReportParameter() { Name = "Pass_SP_EndingDebtorAccountNo", Value ="CHRI" });
pdfreq.ReportParameters.Add(new ReportParameter() { Name = "Pass_SP_AsAtDate", Value = DateTime.Now.ToString("MM/dd/yyyy") });
var streamstring = client.Get<string>(pdfreq);
byte[] bytes = Encoding.ASCII.GetBytes(streamstring);
System.IO.File.WriteAllBytes("c:\\install\\testrep.pdf", bytes);