The render method in below code is causing this error: Generate Errorhttp: or more data source credentials required to run the report have not been specified. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: One or more data source credentials required to run the report have not been specified. I have tried adding credentials to the code updating credentials. Can anyone help me figure out how to add credentials and fix this issue? public (bool, string) GenerateReport(ReportRequest reportRequest) { Byte[] a1 = new Byte[5];
EventLog.WriteEntry("SecondSource", "Generate Report1",
EventLogEntryType.Error, 777, 777, a1);
bool success = false;
bool genRptSuccess = false;
bool writeRptSuccess = false;
string resultMessage = "";
int ReportQueueId = reportRequest.ReportQueueID;
string ServerUrl = reportRequest.ServerUrl + "/ReportExecution2005.asmx";
string ReportPath = reportRequest.ReportPath;
string ReportFormat = reportRequest.ReportFormat;
string ReportOutputPath = reportRequest.ReportOutputPath;
ParameterValue[] parameters = reportRequest.parameters;
// parameters[0].Name = "System";
// parameters[0].Value = "0";
ReportExecutionService rs = new ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
// EventLog.WriteEntry("SecondSource", "Generate ReportCreds",
// EventLogEntryType.Error, 777, 777, a1);
rs.Url = ServerUrl;
// Render arguments
byte[] resultFileBytes = null;
string reportPath = ReportPath;
string format = ReportFormat.Trim();
string historyID = null;
// if (parameters != null)
// {
// foreach (ParameterValue rp in parameters)
// {
// EventLog.WriteEntry("SecondSource", "Generate Report000" + "Name: {0}" + rp.Name + "Value: {0}"+ rp.Value, EventLogEntryType.Error, 777, 777, a1);
// }
// }
// EventLog.WriteEntry("SecondSource", "Generate Report000" ,
// EventLogEntryType.Error, 777, 777, a1);
// string devInfo = System.IO.File.ReadAllText("../../../ReportRunner.Processor/Resources/ReportRunnerConfig.xml");
//string devInfo = System.IO.File.ReadAllText("c:/ReportingSystem/ReportRunnerConfig.xml");
string devInfo = Properties.Resources.ReportRunnerConfig;
DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
string extension;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
DataSourceCredentials datasetCredential = new DataSourceCredentials();
datasetCredential.Name = "XXXXXXXXXXXXXX";
datasetCredential.UserId = "XXXXXXXXXXXXXX";
datasetCredential.Password = "XXXXXXXXXXXXXX";
// DataSourceCredentials[] credentials = new DataSourceCredentials[1];
credentials[0] = datasetCredential;
//rs.SetExecutionCredentials2(credentials);
//rs.Credentials = credentials[1];
// ReportExecutionService reportExecutionService = new ReportExecutionService();
// var creds = new DataSourceCredentials[1];
// creds[0] new DataSourceCredentials() { datasetCredential.Name = "DynamicDataSource", UserName = ReportUserDomain + @"\" + ReportUserAccount, Password = ReportUserPassword };
// reportExecutionService.LoadReport(reportPath, null);
// var creds = new DataSourceCredentials[1];
// creds[0] = new DataSourceCredentials() { Name = "XXXXXXXXXXXXXX";, UserId =
//ReportingService service = new ReportingService();
// rs.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
ExecutionInfo execInfo = new ExecutionInfo();
ExecutionHeader execHeader = new ExecutionHeader();
//reportPath = reportPath.Replace("/", "\\");
//EventLog.WriteEntry("SecondSource", "Generate Report3"+ reportPath,
// EventLogEntryType.Error, 777, 777, a1);
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportPath.Trim(), historyID);
rs.SetExecutionParameters(parameters, "en-us");
String SessionId = rs.ExecutionHeaderValue.ExecutionID;
resultMessage = "SessionID: " + rs.ExecutionHeaderValue.ExecutionID;
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID);
//EventLog.WriteEntry("SecondSource", "Generate Report4",
// EventLogEntryType.Error, 777, 777, a1);
// EventLog.WriteEntry("SecondSource", "Generate ReportXXY" + "parameters1" + parameters[0].Name + parameters[0].Value +"parameters2" + parameters[1].Name + parameters[1].Value + "parameters3" + parameters[2].Name + parameters[2].Value + "parameters4" + parameters[3].Name + parameters[3].Value + "parameters5" + parameters[4].Name + parameters[4].Value, EventLogEntryType.Error, 777, 777, a1);
try
{ if (format == "WORDOPENXML") format = "WORD";
// EventLog.WriteEntry("SecondSource", "parameters" + parameters + "report" + reportPath + "format" + format + "devInfo"+devInfo,
// EventLogEntryType.Error, 777, 777, a1);
resultFileBytes = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
execInfo = rs.GetExecutionInfo();
// EventLog.WriteEntry("SecondSource", "Generate Report5",
// EventLogEntryType.Error, 777, 777, a1);
if (resultFileBytes == null)
{
// EventLog.WriteEntry("SecondSource", "Generate Report6",
//EventLogEntryType.Error, 777, 777, a1);
RS_QueueService rs_QueueService = new RS_QueueService();
string processErrorMessage = "Render Report is null ExecutionInfo : " + execInfo;
rs_QueueService.UpdateIsProcessingError(genRptSuccess, ReportQueueId, processErrorMessage);
}
else
{
// EventLog.WriteEntry("SecondSource", "Generate Report7" + "parameters" + parameters + "report" + reportPath + "format" + format + "devInfo" + devInfo,
//EventLogEntryType.Error, 777, 777, a1);
genRptSuccess = true;
}
}
catch (SoapException e)
{
EventLog.WriteEntry("SecondSource", "Generate Error" + ServerUrl+"aa"+reportRequest.ReportOutputFileName+"BB" + e.Message+e.InnerException,
EventLogEntryType.Error, 777, 777, a1);
Console.WriteLine(e.Detail.OuterXml);
RS_QueueService rs_QueueService = new RS_QueueService();
string processErrorMessage = e.Message + " ExecInfo : " + execInfo;
rs_QueueService.UpdateIsProcessingError(genRptSuccess, ReportQueueId, processErrorMessage);
}
I tried adding credentials to the c# but not sure how to do this. I updated credentials in SSRS. Expecting render method to process SSRS report.