Search code examples
c#powerbinuget-packagepower-bi-report-server

.NET PowerBIClient NuGet Package adds wrong relative URI


I try to encapsule our PowerBI Server REST API via the PowerBI Client NuGet Package from Microsoft. I ran into the problem that the URI gets a wrong relative path added. The REST API of our Reporting Server (on-premise) has a base URI like: https://niceReportingURL.com/reports/api/v2.0 but the NuGet package adds another "/v1.0/myorg" to the URI, which is not necessary.

So resulting of that, the request URI looks like this: https://niceReportingURL.com/reports/api/v2.0/v1.0/myorg

I saw in the source code of the class "ReportsOperations" that this weird relative URI gets added hardcoded!

string uriString = new Uri(new Uri(absoluteUri + (absoluteUri.EndsWith("/") ? "" : "/")), "v1.0/myorg/reports").ToString();

I omitted the "/Reports" in my example URIs because it looks like a general problem. Is there an option or workaround that the NuGet Package doesn't add this relative URI?

The request looks like this:

var c = new BasicAuthenticationCredentials
        {
            UserName = "reportingUser",
            Password = "secretReportingPW"
        };

var client = new PowerBIClient(new Uri("https://niceReportingURL.com/reports/api/v2.0"), c);

var result = await client.Reports.GetReportsAsync().ConfigureAwait(false); // Here comes the fail

Solution

  • The PowerBI Client package encapsulates access to the PowerBI REST API.

    This API is distinct from the Reporting Services REST API, which appears to have no ready-made NuGet package that encapsulates it, but does have an OpenAPI specification that makes it easy to use.

    Both APIs have endpoints for retrieving reports, but they're different kinds of report. Confusingly, Microsoft has chosen to rebrand Reporting Services as "paginated reports" in the PowerBI ecosystem, so at least some Reporting Services reports can be retrieved using the PowerBI REST API. For reports hosted by an on-premise Reporting Services instance, though, you want the Reporting Services API and can't use the PowerBI REST API.