【问题标题】:How do you send an array of parameter values to SSRS via HTTP Post?如何通过 HTTP Post 向 SSRS 发送参数值数组?
【发布时间】:2023-03-19 06:45:02
【问题描述】:

我正在尝试让 SSRS 生成 PDF 格式的报告并捕获字节流以将它们保存到磁盘。如果我必须发送的唯一报告参数是单个值,这可以正常工作,但如果我必须为特定参数发送一组值,则它不再有效。

以下工作正常,因为我只发送一年的价值。通过 UI,Year 参数将是一个多选。

        string parameters = "rs:Command=Render&rs:format=PDF&Year=2018"
        byte[] paramHeader = Encoding.ASCII.GetBytes(parameters);
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL);
        req.PreAuthenticate = true;
        req.Credentials = new System.Net.NetworkCredential(
            reportUser,
            reportUserPW,
            reportUserDomain);

        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = paramHeader.Length;

        using (var stream = req.GetRequestStream())
        {
            stream.Write(paramHeader, 0, paramHeader.Length);
        }

            HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
            Stream fStream = HttpWResp.GetResponseStream();
            File.WriteAllBytes(JobId.ToString() + "\\employeeName.pdf", copyStreamToByteArray(fStream));

如果我将参数字符串更改为具有多个年份值,则会失败:

string parameters = "rs:Command=Render&rs:format=PDF&Year=2018,2017,2016"

我在使用 Reports Services UI 时尝试查看网络流量,以查看它如何使用 Fiddler 将参数发送到 SSRS,但无法从中获取任何有用的信息。它看起来像是被编码在某种 ViewState 字符串中。

如何在 Post 标头中发送给定 SSRS 参数的值数组?

【问题讨论】:

    标签: .net reporting-services


    【解决方案1】:

    要完成这项工作,只需对每个附加值重复该参数,如下所示:

    string parameters = "rs:Command=Render&rs:format=PDF&Year=2018&Year=2017&Year=2016"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-15
      • 2011-05-11
      相关资源
      最近更新 更多