Connect Web API as a data source to power bi using authentication - powerbi

I have azure web api app with number of web apis of type post/get to get data. these apis are having basic authentication (bearer token)
I want to use 2-3 APIs as a data source in power bi, so that I can use these APIs JSON response as a table.
In Power BI Desttop > Get Data > Web > add API URL with sample GET API method name, will work but then it is asking for authentication.
If I tried to put API Key, then it is saying: A web API key can only be specified when a web API key name is provided.
How to connect web api using authentication in power bi as a data source.

PowerBI web seems to currently have little or no support for connecting to data via webapi, or web queries generally.
PowerBI Desktop allows you to get data from the web. I have been able to access data from webapis managed by Azure API Management in two different ways:
Use Advanced rather than Basic in the From Web dialog box. Put the webapi query in the url, but add a header with name Ocp-Apim-Subscription-Key and put in as value the value of the api key.
Alternatively, instead of putting the api key in the header, with APIs managed by Azure API management, it seems you can add them to as a parameter to the apiquery, subscription-key=PutYourApiKey here.
However, I have found that although you can publish your data source or report to an online workspace, PowerBI online will give an error ("credentials not recognized" or similar) when you try and refresh the data! So as mentioned above, PowerBI online seems currently (Nov 2020) useless for connecting to WebApi data.

Related

Query (HTTP GET) data in Power Apps Portal from Web API with JavaScript

I have a "Starter Portal" Power App Portal. I would like to utilize JavaScript and the Web API for querying data. Documentation states
You can use the Web API to perform create, update, and delete operations across all Microsoft Dataverse tables from your portal pages.
Further documentation only lists the CREATE, UPDATE, DELETE operations, and this API being accessible as
[Portal URI]/_api
And I have found how to successfully authenticate using a helper method to get a token for the header:
shell.getTokenDeferred().done(function (token) { ...}
This allows authentication as the user logged into the portal so I believe all relevant Table Permissions, etc. are applied.
But, I would like to retrieve data (HTTP GET). I know this is possible from the Dataverse Web API.. This api is exposed as
[Organization URI]/api/data/v9.1/
Are these really the same API, just exposed a different way for the portal? Is it possible to use the GET endpoints or the second API altogether, authenticated as a Portal Contact user like the previous operations?
It's the same API but permissions are different, you will need to enable the tables you want to access inside the _api endpoint.
You can read more info at this page: https://learn.microsoft.com/en-us/powerapps/maker/portals/read-operations, there is also an XrmToolBox tool to assist you in this operation (but I didn't try it) https://www.xrmtoolbox.com/plugins/PowerPortalWebAPIHelper/
Regarding the Web API calls, I released a new tool to create them (similar to CRM REST Builder) I also added a "Portals" syntax (is in preview) but the generated urls are the same. Link: https://github.com/GuidoPreite/DRB

Connecting REST API to Tableau

I am trying to use REST API to connect data into Tableau Desktop. Which option do I select when choosing the datasource when opening Tableau Desktop? I have tested the API in Postman, and it successfully connects.
The REST API is not a data source that can be accessed from Tableau Desktop. To use the REST API you have to export the data from an API call to csv or other flat file. Then you can connect Tableau Desktop to that file. You can automate this using Python. You can also export directly from Postman. At the top of your results after you run your GET, download the file from here
I do strongly recommend you do this all in Python rather than Postman though so you can consume the json file much more easily with pandas. I would also recommend looking at tableauserverclient within Python rather than using the API directly. tableauserverclient is more limited than the API but will likely have the functionality you need.
Tableau cannot connect to REST API directly.
One way is to use Web Data Connector, BUT you have to build a web page for each REST API and paste the web page link in Web Data Connector.
Alternatively, you can use ETL tools that support extracting data from API and loading it to Tableau. (I personally recommend Acho. Its API connector is very useful)

How to call the Power BI Activity Log API

I would like to call the Power BI Activity Log API with data factory each day to download the activity events into a blob store. I thought I'd use a Copy data activity with an HTTP dataset as source to call the REST API. How do I authenticate in the HTTP dataset's linked service? Do I need to register an Azure AD application with Power BI admin rights and refer to it in some way in the linked service?
Maybe you can have a look at Service Principals, it can help you to easily authenticate and access Power BI admin read-only APIs (ActivityEvents API included) without tying you to a particular user account. Its in preview feature as of today, but should be soon out of preview.
Also, for automating the fetching of logs using Azure Data Factory and ingesting it in Azure Blob, you may have a look at this great article which explains in detail, all the steps that will be required to create the pipeline. Should be helpful!

Embedding Power BI reports in to Angular application

I am trying to embed a Power BI reports in to our Angular application. We are currently using Identity server to authenticate and get the security token back from Azure Active Directory. Can that token be used in embedding the Power BI reports in to our application or is it mandatory to register a application in azure which will help in embedding reports
You must register an application to establish an identity for your application and specify permissions. Both the access token and the app ID are used when embedding Power BI elements into your application. It is recommended for the actual embedding to also use embed token generated by GenerateTokenInGroup or similar, because the authentication token will be exposed in JavaScript client code of your application and can be seen. AAD tokens can be exploited to call other REST API functions, etc., while embed tokens are valid only for embedding this one element only and expires in less time.
For detailed information how to embed Power BI see Embed reports or dashboards from apps.
To embed Power BI without registering an application, you can use Publish to web or Embed. The first one will give public access to everyone who knows the link (note it has some limitations), while for the second option each user will need Pro account, unless you are using Power BI Premium or Embedded (and note its limitations too).

how to connect my web api wtih Power BI Reports?

I have a web API to deliver required data sources for my reports. How can I connect my web API with Power BI. I gone through Rest API. But I am missing the complete flow.
Go to Home > Edit Queries > Advance Editor. Here is some Power Query code to query issue a GET request to an API endpoint.
let
Source = Json.Document(Web.Contents("http://mywebapi"))
in
Source
More information here: https://msdn.microsoft.com/en-us/library/mt260892.aspx
and here: https://blog.crossjoin.co.uk/2014/03/26/working-with-web-services-in-power-query/