cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iperezal Frequent Visitor
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
Super User
Super User

Re: Best way to change from PBI Desktop to Web?

Sounds like you need to use the Enterprise Gateway.


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


iperezal Frequent Visitor
Frequent Visitor

Re: Best way to change from PBI Desktop to Web?

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.

AlanBourke Frequent Visitor
Frequent Visitor

Re: Best way to change from PBI Desktop to Web?

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.

 

 

 

 

 

 

 

 

 

iperezal Frequent Visitor
Frequent Visitor

Re: Best way to change from PBI Desktop to Web?

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?

Highlighted
iperezal Frequent Visitor
Frequent Visitor

Re: Best way to change from PBI Desktop to Web?

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