How to export SSRS 2017 report using REST API

后端 未结 3 1184
北荒
北荒 2021-02-20 17:01

I\'ve setup SSRS 2017.I need to export an SSRS report using their new REST API, I\'ve been looking through the API specification here but I can\'t find a method in swagger speci

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-20 17:26

    Selenium's .Net DLLs can be used to invoke the report, including setting any report parameters.

    The trick is that the ReportViewerControl emits the parameters and the "View Report" button within an IFRAME. The "ChroPath" Chromium extension can be used to help get full XPath paths to elements in a page, but that path may not actually work with the Selenium APIs.

    But if you "set the focus" into the IFRAME:

    # from my Powershell script that does this...

    #first, switch to the reportviewercontrol IFRAME:

    [void] $seldriver.SwitchTo().frame(0)

    ...then you should be able to access any of the HTML elements within the IFRAME with relative XPath queries ala

    $xpath = "//*[@id='ReportViewerControl_ctl04_ctl03_txtValue']"

    To run the report, you'd invoke the Click event on the "View Report" button.

    The big caveat is that the HTML elements emitted by the ReportViewerControl have pretty dry, serially generated names and IDs. But with Selenium, you can try to access them in a variety of ways.

    For Powershell users, the "Selenium" powershell module is useful. But you'll need to dip into the .DLLs for things like switching to the ReportViewerControl IFRAME.

    Another thing I found I needed to do is throw in liberal sleep N #n seconds commands to let parts of the report finish rendering and get pulled into their containing variables.

    At least that's what I have done in my Powershell script.

    I am not sure that the Selenium APIs really throw any events for page rendering, even though invoking a report seems like it'd be inherently an asynchronous action. The Selenium API does in theory support setting explicit timeouts (as well as implicit timeouts), etc.

    So, in my case, I want to invoke all the reports on my SSRS server to see if they actually run. Selenium seems like a good way to "interact" with the reports in a web browser.

提交回复
热议问题