Forum Discussion
Anonymous
1 year agoNot applicable
XML parameter not working in embed paginated report URL
Hi, I am trying to pass xml as parameter in embed url as rp variable though my asp.net framework application level. Please can you help me with this. string P_ID = '<Pr><id>25</id><id>32</i...
SolomonovAnton
Super User
1 year agoWhy the raw XML fails
- Characters such as <, >, & and quotes have reserved meanings in a URL. They must be percent-encoded; otherwise the service truncates or rejects the query-string.
- Paginated Report parameters are always received as plain text. If you send an XML fragment you’ll parse it later in the dataset/query.
Recommended approach
- In the report:
- Create parameter P_IDS as type Text, allow blank.
- Inside the dataset (SQL Server example) turn the string back into XML:
DECLARE @xml xml = @P_IDS; SELECT x.i.value('.', 'int') AS ID FROM @xml.nodes('/Pr/id') x(i);
- In ASP.NET (Framework) encode the parameter value before concatenating it to the embedUrl:
using System.Web; // for HttpUtility
var pIdXml = "<Pr><id>25</id><id>32</id></Pr>";
var start = startDate.ToString("yyyy-MM-dd"); // format counts!
var end = endDate.ToString("yyyy-MM-dd");
var query =
$"rp:P_IDS={HttpUtility.UrlEncode(pIdXml)}" +
$"&rp:START_DATE={start}" +
$"&rp:END_DATE={end}";
var embedUrlWithParams = $"{embedInfo.embedUrl}?{query}";
Key points
- Use HttpUtility.UrlEncode (or Uri.EscapeDataString in .NET Core) on every parameter value that might contain reserved characters.
- Ensure the base embedUrl already ends without a query part; add ? once, then & for subsequent parameters.
- If the report only needs multiple numeric IDs you can skip XML entirely and pass them as a multi-value parameter:
Full Microsoft guidance: Paginated Reports – URL parameters
Try building the URL with the encoding applied and refresh the embedded viewer; you should now see the parameter values arriving intact. If parsing or report execution still fails, copy the final URL into a browser address bar to confirm the encoded XML string is complete.
|
✔️ If my message helped solve your issue, please mark it as Resolved! 👍 If it was helpful, consider giving it a Kudos! |