Power BI to Trigger API Call

Hi All,

I have a need to create a simple dashboard/report that will contain 1 button that users will press to trigger an API call. This is done by simply hitting a URL. I can link a URL to a button but it opens a separate web browser and launches the URL. Is it possible to hit the the URL without opening a browser?

I’d also like to have a card/table that shows when and preferably who pressed the button last. Any links/ideas on how I’d achieve this would be appreciated.

Cheers,

Marcus

This is quite unique and I’m not sure I know the exact answer, but my guess is no on the URL issue.

Can you just link it to an image another way.

I personally haven’t used API calls so not a huge amount of value I can add right now sorry.

Maybe someone else can assist here.

I’m interested to learn more about API calls myself.

Thanks
Sam

Hi @Marcus,

I can provide a couple ideas based on what I do with framework-based web application development. It might be possible to call a custom page from your button click and have the page 1) register the button click in a database table, 2) redirect to the API, and 3) close the window.

I believe it is your local browser that opens the new tab/window when clicking on a URL, and requiring a window to open is for security purposes. Browsers may also prompt the user to confirm it is okay to have a script close the window depending on the security context.

If you have the ability to create and host a custom web page, I recommend creating one that your report button accesses when clicked. I use ASP.NET, but other options exist that can do each of the things needed.

You need a data table or storage mechanism to capture the log of button clicks. An ASP.NET page code-behind can be used to connect to the data store and insert a record of the click. You will also have access to any parameters sent in via query string in the URL, other web page instance info, and potentially user info.

Once the log data is in a table, it can be loaded into the Power BI report to provide a card/table as indicated.

The custom page can then redirect to the target API URL, and potentially even wait for a response and process/log it.

Finally the custom page can use JavaScript or jQuery to close the window. I use the following code extensively to close popup windows in my Intranet applications without a user prompt.

function closeWindow() {
window.top.close();
if (window.top.opener && !window.top.opener.closed){window.top.opener.focus();}
}

If you also need to refresh the parent window that opened the new window, you can use the following JavaScript that also calls the closeWindow() function above:

this.opener.location.reload(true); closeWindow();

Hope this helps!

John C. Pratt
Enterprise%20DNA%20Expert%20-%20Small