Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello
I used the REST API to update Power BI Reports with a C# Application, but I had no luck with updating the PowerBIReport DataSource. I have a connection to an on-prem Anaysis Services Tabular.
I tried it as it is described here: https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/
Sections:
GET /PowerBIReports({Id})/DataSources --> Works fine
PATCH /PowerBIReports({Id})/DataSources --> NO LUCK, always (400) Bad Request.
PUT instead of PATCH gives (405) Method Not Allowed
Are there C# examples? For me, just the Swagger is not enough to understand what I have to do...
Greetings,
Roli
Solved! Go to Solution.
OK, here my experiences with the Swagger on 2018-02-03 (can vary if you do it after that date because of updates)
Create IO.Swagger Assembly
ManifestItem.ToJson()
public virtual string ToJson()
Use IO.Swagger Assembly in your Application
using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; using RestSharp;
var clientCI = new CatalogItemsApi(apiString); clientCI.Configuration.ApiClient.RestClient.Authenticator = new NtlmAuthenticator(CredentialCache.DefaultCredentials); ODataCatalogItems cItems = clientCI.GetCatalogItems();
Updating PowerBIReports DataSources
//Get PowerBIReport var clientPBIR = new PowerBIReportsApi(apiString); clientPBIR.Configuration.ApiClient.RestClient.Authenticator = new NtlmAuthenticator(CredentialCache.DefaultCredentials); PowerBIReport pbir = clientPBIR.GetPowerBIReport(id); //Update ConnectionString ODataDataSources odataDS = clientPBIR.GetPowerBIReportDataSources(id); odataDS.Value[0].ConnectionString = "..." //To be replaced clientPBIR.UpdatePowerBIReportDataSource(id, odataDS.Value);
Happy coding!
Roli
OK, here my experiences with the Swagger on 2018-02-03 (can vary if you do it after that date because of updates)
Create IO.Swagger Assembly
ManifestItem.ToJson()
public virtual string ToJson()
Use IO.Swagger Assembly in your Application
using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; using RestSharp;
var clientCI = new CatalogItemsApi(apiString); clientCI.Configuration.ApiClient.RestClient.Authenticator = new NtlmAuthenticator(CredentialCache.DefaultCredentials); ODataCatalogItems cItems = clientCI.GetCatalogItems();
Updating PowerBIReports DataSources
//Get PowerBIReport var clientPBIR = new PowerBIReportsApi(apiString); clientPBIR.Configuration.ApiClient.RestClient.Authenticator = new NtlmAuthenticator(CredentialCache.DefaultCredentials); PowerBIReport pbir = clientPBIR.GetPowerBIReport(id); //Update ConnectionString ODataDataSources odataDS = clientPBIR.GetPowerBIReportDataSources(id); odataDS.Value[0].ConnectionString = "..." //To be replaced clientPBIR.UpdatePowerBIReportDataSource(id, odataDS.Value);
Happy coding!
Roli
could you help me some tips? how to upload a pdix file to the power BI server in the
using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model
var clientCI = new CatalogItemsApi(apiString); clientCI.Configuration.ApiClient.RestClient.Authenticator = new NtlmAuthenticator(CredentialCache.DefaultCredentials); clientCI .upload()//how to use the api? thanks very much