Hi it might seem as a reporting service question but as I try to generate CRM reports that uses FetchDataSource I still assume that it is a CRM question.
Here is my problem:
I use URL access to generate report. See code below. If 'Custom invoice report' uses data that requires user name and password to be PROMPTED (Credentials supplied by the user running the report) then, as far as i understand, dsu:datasourcname and dsp:datasourcename parameters should be used to pass these values. But the error i get is
- The data source '/CRMORGNAME_MSCRM/MSCRM_FetchDataSource' cannot be found. (rsDataSourceNotFound) Get Online Help
On the other hand, if i change data source used by the report so that it uses 'Store credentials' (Credentials stored securely in the report server) instead and again provide the same username and password (i.e. userid and organisationid) and remove dsu:datasourcename and dsp:datasource name parameters from the code below then I can generate the report file. Could anyone tell me what am I doing wrong? or 'Store credentials' is the only way to get the report generated on fly for fetchxml reports?.
Thank you!
string url = string.Format ("http://reportservername/reportserver?{0}{1}", HttpUtility.UrlEncode("/CRMORGNAME_MSCRM/Custom Invoice"), string.Format("&rs:Command=Render&rs:Format=PDF&rc:Toolbar=false&dsu:{0}={1}&dsp:{0}={2}", HttpUtility.UrlEncode("/CRMORGNAME_MSCRM/MSCRM_FetchDataSource"), HttpUtility.UrlEncode("{user guid}"), HttpUtility.UrlEncode("{organization guid}"))); WebRequest request = WebRequest.Create(url); int totalSize = 0; request.UseDefaultCredentials = true; request.Method = "GET"; request.ContentLength = 0; WebResponse r = request.GetResponse(); using (BinaryReader s = new BinaryReader(r.GetResponseStream())) { using (FileStream writer = File.OpenWrite("test.pdf")) { byte[] buffer = new byte[2048]; int count = s.Read(buffer, 0, 2048); while (count >0) { totalSize += count; writer.Write(buffer, 0, count); count = s.Read(buffer, 0, 2048); } writer.Flush(); } }
Kotena