Power BI REST API No Code Options for Easy Data and Reports Download

Microsoft’s Power BI REST API no-code option is extremely helpful as it allows calling Power BI REST API without writing a single line of code. Of course, you can call it programmatically using any programming language. Still, testing if Power BI Rest APIs are accepting requests and returning the right data, it is convenient to use the no-code options first. This article will explain how to do that.

CodingSight - Power BI REST API No Code Options

Power BI Sample Data Import

In our tutorial, we are going to use the Power BI Service. It is a cloud-based platform for viewing and manipulating reports. Initially, analysts created reports in the Power BI desktop software and then distributed them to other users via the Service. Now, the functionality of the Power BI Service is more advanced.

So, you can import the data in CSV, Excel, or other supported formats, and create reports directly in the cloud, without installing the software. The process is similar to the desktop (learn more on what is Microsoft Office Power BI).

We’ll start by importing a dummy dataset in CSV or Excel into the Power BI service. Then, we create dummy reports using that dataset. Finally, we’ll explore the usage of Power BI REST API No Code Options for accessing the dataset and reports.

To import the dataset, log in to your Power BI account. Once you are there, you should see the following dashboard:

To import the dataset, login to your Power BI account

The dataset that we are going to import is available free of charge here:

https://www.kaggle.com/rtatman/animal-bites?select=Health_AnimalBites.csv

Download the CSV file (there can be other formats, for instance, Excel). As it is defined in the dataset description, it “includes the information on over 9,000 animal bites which occurred near Louisville, Kentucky from 1985 to 2017, and the information on whether the animal was quarantined after the bite occurred and whether that animal was rabid.

You need to create a Workspace before you can actually import the dataset. For that, click My workspace on the Dashboard.

To import the dataset, click New > Dataset:

To import the dataset, click New > Dataset

Here you can import data from various sources such as services, flat files, databases, etc. Since the dataset we want to import is a CSV file, click Get in Files section:

Here you can import data from various sources such as services, flat file, databases etc. Since the dataset we want to import is a CSV file, click Get in Files section

As you can see from the below screenshot, it is possible to import files from various sources. Our CSV file is stored on the local drive. Hence, select Local File and browse to the necessary location of that CSV file:

Select Local File and browse to the necessary location of that CSV file

Once you’ve imported the file, you should see it in the dataset list in the workspace. In our case, it is the Health_AnimalBites dataset:

Once you've imported the file, you should see it in the dataset list in the workspace. In our case, it is the Health_AnimalBites dataset

How to Create Report in Report Builder

Now we can create reports. Click three vertical dots next to the dataset name – and select Create report from the drop-down menu:

Now we can create reports. Click three vertical dots next to the dataset name – and select Create report from the drop-down menu

After that, you will get the Power BI reports View window with different types of visualization. In the Fields pane, you will see the columns of your CSV file:

After that, you will get the Power BI reports View window with different types of visualization. In the Fields pane, you will see the columns of your CSV file

To create a new report, select the visualization type and add column values to display.

Let’s plot a clustered column chart that shows gender count for all the species of animals:

  • Select the clustered column chart visualization highlighted in the screenshot below.
  • In the Axis field, drag and drop the SpeciesIDDesc column – it contains values for different animals’ species.
  • In the Values field, drag the GenderIDDesc column. The description of that column will change to Count of GenderIDDesc automatically since the Values field of the clustered column chart displays counts of unique values in a categorical column by default.
  • We want to display the count of gender for each gender. Thus, add GenderIDDesc in the legends field.
Let's plot a clustered column chart that shows gender count for all the species of animals

When the report layout is fine for you, click Save and then give a name to that report. We save our report as specie_gender.

When the report layout is fine for you, click Save and then give a name to that report. We save our report as specie_gender

The saved report opens automatically.

The saved report opens automatically

Our example displays that the number of people bitten by male dogs is almost twice higher than those bitten by female dogs. At the same time, the ratio of people bitten by male and female cats is equal. One may assume that male dogs are more aggressive than female dogs while female and male cats are equally aggressive.

Download Datasets using Power BI REST API

We have set up our dataset and created reports. By default, Power BI provides REST API that you can apply to access datasets and reports using any programming language. However, Microsoft has made it easier. As we mentioned earlier, we can test the API and see if it delivers the desired results, and we won’t need to write a single line of code. If the results of your API call satisfy you, you can then call Power BI REST API programmatically.

Let’s see how we can access the Microsoft services to call Power BI rest API. Use the below link:

https://docs.microsoft.com/en-us/rest/api/power-bi/

You will get to the following page:

Power BI REST APIs - REST Operation groups

You can see various options for making calls to Power BI Rest API.

Let’s try to get information about a specific dataset. To do so, click Datasets -> Get Dataset. On the right side, you will see the explanation on how to get the Dataset information.

Let's try to get information about a specific dataset. To do so, click Datasets -> Get Dataset. On the right side, you will see the explanation on how to get the Dataset information

To get the dataset via Power BI REST API, you need the dataset ID. You can find it by clicking the dataset name in your workspace in Power BI Service:

To get the dataset via Power BI REST API, you need the dataset ID. You can find it by clicking the dataset name in your workspace in Power BI Service

Normally, you can access the dataset ID via the following link:

https://app.powerbi.com/groups/me/datasets/{dataset_id}

The {dataset_id} variable corresponds to your unique dataset ID. Copy and paste that dataset ID. Go back to Microsoft services for Power BI REST API page and paste the dataset ID into the datasetId field:

The {dataset_id} variable corresponds to your unique dataset ID. Copy and paste that dataset ID. Go back to Microsoft services for Power BI REST API page and paste the dataset ID into the datasetId field

Click Run.

You will see the JSON response returned by your Power BI Server. It will include the dataset details along with the dataset name, ID, user who configured the dataset, etc.

You will see the JSON response returned by your Power BI Server. It will include the dataset details along with the dataset name, ID, user who configured the dataset, etc.

Now you can see how simple it is to make a Power BI API call without having to write any code.

Download Power BI Sample Reports (No-Code Example)

Let’s see another example – try to get a report. Click Reports > Get Report. In that window, click Try It

Let's see another example – try to get a report. Click Reports > Get Report. In that window, click Try It

It will ask you to enter the ID of the report you want to access:

It will ask you to enter the ID of the report you want to access

To get the report ID, go to the Power BI dashboard and select the report you want to get via a call to the Power BI Rest API. In our example, we are accessing the specie_gender report. 

You can access the report ID via the following link:

https://app.powerbi.com/groups/me/reports/{report_id} /ReportSection

The {report_id} is the ID of your report.

The {report_id} is the ID of your report

Enter that value into the reportID field and click Run.

You should see the following JSON response with the report name, the ID of the database containing the report, the web URL of the report, etc.

You should see the following JSON response with the report name, the ID of the database containing the report, the web URL of the report, etc.

Conclusions

The Power BI Rest API no-code options are extremely powerful. They do lots of things above providing you with the information about datasets and reports on the Power BI Server. You can also update them at runtime, all without writing a single line of code.

Related Articles

  1. Loading and Managing Data within Microsoft Power BI
  2. Power BI Custom Data Visualization

Ben Richardson
Latest posts by Ben Richardson (see all)

Ben Richardson

Ben Richardson runs Acuity Training. Acuity is an IT training business offering classroom courses in London and Guildford. It is a leading provider of SQL training the UK and offers a full range of SQL training from introductory training to advanced administration courses.

Leave a Reply

Your email address will not be published. Required fields are marked *