REST APIs are very common in enterprise environments today for exposing and consuming data. Although it simplifies data access, access control and platform dependency, it gets tricky if you want to access data from these REST APIs via Power BI. You have to write custom code to handle authentication, pagination, and normalization, not to mention keep it up-to date whenever the REST API changes.
With Progress DataDirect Autonomous REST Connector, you will be able to easily connect to any REST API in your enterprise from Power BI without having to write any code. In this tutorial, we will walk you through how you can connect to any REST API from Power BI, use DirectQuery to get data from your REST API to Power BI and publish the report to Power BI Online which can refresh the dataset by using DirectQuery. Let’s get started.
You can use the Autonomous REST Connector for ODBC directly with Power BI; however, to use the DirectQuery functionality, you must install the Power BI connector that is included with the Autonomous REST Connector. To install the Power BI connector:
- Navigate to the
\tools\Power BI
subdirectory of the Progress DataDirect installation directory; then, locate the installation batch file install.bat
.
- Run the
install.bat
file. The following operations are executed by running the install.bat
file:
- Open or restart Power BI to use the connector.
- Once you have published your reports online for sharing, you will also want to refresh the reports with latest dataset to keep the information up to date. But the source of your data (REST API) is accessible from your on-premises environments only. To enable refreshing data from on-premises databases and REST API’s you need to install the on-premises data gateway from Microsoft on the machine where you configured the ODBC Connector.
- Download Data GateWay from Power BI Service. You should find the download option as shown below.
- Install Data Gateway and log in to your Microsoft account during the setup process. Make sure you use the same account you have used to publish the report online from Power BI Desktop.
- Go to C:\Users\{username}\Documents\Power BI Desktop\Custom Connectors where you copied the connector in the previous section and open the properties of Custom Connectors.
- Go to Security Tab -> Advanced-> Add -> Select a New Principal to add the Service Account NT SERVICE\PBIEgwService to access the Custom Connectors folder. The Data Gateway uses this service account to run the services, so we need to make sure this service account has access to Custom Connectors folder.
- Change the Location to the machine name and add NT SERVICE\PBIEgwService. Click on Check Names to validate the service account and click on OK.
- Save the security permissions and make sure NT SERVICE\PBIEgwService has access to the Custom Connectors folder before you leave.
- Now open On-premises Data gateway. Go to the Connectors tab and replace the path with the below:
C:\Users\{username}\Documents\Power BI Desktop\Custom Connectors
This is the same Custom Connectors folder we have added our connector to and made sure there is access to the service account NT SERVICE\PBIEgwService.
- Click on Apply and you should now see all the connectors in the folder displayed in the Data Gateway.
- Go to Power BI Service, Settings -> Manage Gateways and you should see the gateway you just installed. Under the Gateway settings, Check the option Allow User’s custom data connectors to refresh through this gateway cluster as shown below. Click on Apply to save the settings.
- Go to the Settings -> Data Sets tab and you should see the dataset you published to Power BI Online in the previous section. Under Gateway connection, you should see an error “Not configured Properly”. Click on Actions and you should now see an option to “Manually add to gateway”. Click on it.
- This should take you to Gateway Settings to Add a New Data Source under the gateway. Under DSN Name, enter the ODBC DSN Name you have created on your machine and click on Add. This validates the connection and if it’s successful, the data source gets created.
- Now go to Settings -> Data Sets -> Your Data Set -> Gateway Connection. You should see Status as running and there should be a new dropdown Maps to choose the data source that you have just created above. Click on Apply.
- Now you can schedule refresh for your data set under Scheduled Cache Refresh as shown below.
- Or you can refresh your report on-demand from the report settings. The data set will get refreshed by sending a query to your REST API in real-time with the help of Progress DataDirect Autonomous REST Connector.
We hope this tutorial helped you to DirectQuery your REST API from Power BI Desktop as well as Power BI Online Service using Progress DataDirect Autonomous REST Connector. If you have any questions, please
contact us and we will be happy to help you.