Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
iperezal
Frequent Visitor

Best way to change from PBI Desktop to Web?

I've developed a software in Java that proccess and generate info in JSON format. Actually, I'm saving this info in a .json file and it's my data source in PowerBI Desktop, wich have some dashboards. When I run my software and get new data hit the Refresh button in Power BI Desktop to update the graphics and Dataset.

 

Now I need to change Web versión. 

I tried to do up the file .pbix to OneDrive but if the file does not change fails. Another way I've tried is through personal Gateway, this works for one user, but I need this to work for multiple users who may not be in the same PC where the file is located.

My last attempt was through the rest API Power BI, again got authenticate error in azure. Besides this is somewhat difficult because most examples are in c# and I am developing in Java.

5 REPLIES 5
iperezal
Frequent Visitor

I have another question: Rest Api only works for 1 user?

Greg_Deckler
Super User
Super User

Sounds like you need to use the Enterprise Gateway.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

What I need to use Rest API? I get errors when i try to use it.

 

Rest api should be easiest to use. Authenticate by Azure AD is tricky and dificult, and you need a lot of permissions and steps to make it work.

I found it quite straightforward by registering the app with Azure AD and getting the Client ID string from that.

 

Then you just use the client ID to get an authorisation token, and use the token in any Power BI API requests.

 

So if I wanted to create a dataset I first get a token using my client ID, see the GetToken() example here.

 

When I have the token I can create a dataset like this (I use the RestSharp package to make REST API  calls easier)

 

        public string CreateDataset(string token, string json)
        {
            string Resource = "v1.0/myorg/datasets";
            IRestResponse Response = RestRequest(token, Resource, json, Method.POST);

            return Response.Content;
        }

 

The RestRequest method:

 

        public IRestResponse RestRequest(string token, string resource,  string Json, RestSharp.Method HttpMethod)
        {
            //string PowerBIApiAddRowsUrl = String.Format("https://api.powerbi.com/v1.0/myorg/datasets/{0}/tables/{1}/rows", datasetId, tableName);

            var client = new RestClient("https://api.powerbi.com");
            var request = new RestRequest(resource, HttpMethod);
            request.AddParameter("Authorization", String.Format("Bearer {0}", token), ParameterType.HttpHeader);
            request.AddParameter("application/json; charset=utf-8", Json, ParameterType.RequestBody);
            request.RequestFormat = DataFormat.Json;
            IRestResponse response = client.Execute(request);

            return response;
        }

 

The json passed in should be of the form that the API is expecting to define a dataset, as described here. Basically it's just:

{\"name\": \"SalesMarketing\"}

That returns an ID string that you could further use to add tables to the dataset.

 

 

 

 

 

 

 

 

 

Thanks, this works for me, but my problem is that i'm using Java to develop my app. Do you know how to migrate to this language?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.