Use Power Automate HTTP Connector to Publish .pbix File Using the Power BI API

This will describe how to Publish a file from SharePoint to PowerBI.com using Power Automate HTTP Connector to call the API.

You might end up on this blog after looking at Microsoft’s article on this function here: https://learn.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group

Prerequisite Knowledge

  • You know the basics of the Power BI API, including how to setup the Service Principal (App Registration, PowerBI.com Access, etc).
  • You know the basics of using the Power Automate HTTP connector.
  • You can already do *something* successfully with the Power BI API. This blog won’t explain how to authenticate the HTTP connector.

JSON Format for HTTP Body

Here’s the correct JSON for the Body of the HTTP Request

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"TestAPI\"; filename=\"TestAPI.pbix\""
      },
      "body": SharePoint File Content
    }
  ]
}

As you can see in the first screenshot, the text in red can be replaced with Power Automate Variables. I’m using the SharePoint Get File Properties (Name, File Name With Extension) and SharePoint Get File Content (.pbix File) connectors to get these values.

URL and Parameters

Here’s a sample URL. Replace red text with variables or hard code your values.

https://api.powerbi.com/v1.0/myorg/groups/12345678-1234-1234-1234-123456789abc/imports?datasetDisplayName=TestAPI&skipReport=true&nameConflict=CreateOrOverwrite

skipReport=true means you can publish a Dataset only without publishing the Report!

Hat Tip

THANK YOU blogger/MVP Mohamed Ashiq Faleel for writing the post below. There were some pieces to put together, but without this blog I would not have solved this.

https://ashiqf.com/2021/07/25/how-to-use-form-data-and-form-urlencoded-content-type-in-power-automate-or-logic-apps-http-action

2 Replies to “Use Power Automate HTTP Connector to Publish .pbix File Using the Power BI API”

  1. Thanks for your post.
    At the moment I’am stuck.
    I do not know, how to use “Get File Properties” and “Get File Content” to receive the needed content for “body”: SharePoint File Content
    Any help would be appreciated.
    Thank you.
    BR, Hp

    Like

    1. Those are Flow steps using the SharePoint connector. It assumes you have a .pbix file stored in SharePoint or Teams.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s