Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tom-P
Frequent Visitor

Post import to group - Power Automate / Flow

Hi all,

 

I posted this over in the service forum, not realising API discussion should be here!

 

I've followed a number of the guides for connecting to PowerBI REST APIs using a custom connector in PowerAutomate/Flow, and generally have it working well...I'm now succesfully using flows to update parameters, refresh datasets etc.

 

Where I have failed is trying to duplicate a report and dataset, by exporting and importing.

 

I'm using the swagger posted here:

 

https://github.com/microsoft/PowerBI-CSharp/blob/master/sdk/swaggers/swagger.json

 

Flow currently looks like this:

 

Capture.PNG

 

Export is using this:

 

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

 

This is succesful and if I put the body of this into a compose to check it, gives me a zip file, which when downloaded and renamed to .pbix, opens properly.

 

The raw output of the export action is:

 

 

{"statusCode":200,"headers":{"Pragma":"no-cache","Transfer-Encoding":"chunked","X-PowerBI-FileName":"Test File.pbix","Strict-Transport-Security":"max-age=31536000; includeSubDomains,max-age=31536000; includeSubDomains","X-Frame-Options":"deny,deny","X-Content-Type-Options":"nosniff,nosniff","RequestId":"[ID]","Access-Control-Expose-Headers":"RequestId","request-redirected":"true","home-cluster-uri":"https://wabi-uk-south-redirect.analysis.windows.net/","Cache-Control":"no-store, must-revalidate, no-cache","Date":"Wed, 29 Apr 2020 03:27:50 GMT","Content-Type":"application/zip","Content-Length":"1839288"},"body":{"$content-type":"application/zip","$content":"UEsDBBQAAAAIAHg[...rest of the content]"}}

 

 

I'm then trying to take the body of the export and use it with the POST import to group function:

 

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

 

 

I'm getting this error withn a 400 status code:

 

 

 

{
  "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
  "X-Frame-Options": "deny",
  "X-Content-Type-Options": "nosniff",
  "Access-Control-Expose-Headers": "RequestId",
  "request-redirected": "true",
  "home-cluster-uri": "https://wabi-uk-south-redirect.analysis.windows.net/",
  "RequestId": "d248b4cd-7093-4322-893d-ff971cff3b0f",
  "Date": "Wed, 29 Apr 2020 03:01:46 GMT",
  "Content-Length": "0"
}

 

 

 

 

 

 

If i click the "input" of that action, it shows as:

 

 

 

 

 

 

{"host":{"apiId":"subscriptions/[code removed]/providers/Microsoft.Web/locations/uksouth/runtimes/uk-001/apis/pbi-20connector-[code removed]","connectionReferenceName":"shared_pbi-20connector-[code removed]","operationId":"Imports_PostImportInGroup"},"parameters":{"groupId":"[code removed]","datasetDisplayName":"TestCopy.pbix","importInfo":{"$content-type":"application/zip","$content":"UEsDBBQAAAA[...rest of content]"},"nameConflict":"Abort"}}

 

 

 

 

Any ideas what I'm doing wrong?  Has anyone succesfully managed to do this that could point me in the right direction? For easy reference the swagger code for the import to group action is below:

 

 

 

"post": {
                "tags": [
                    "Imports"
                ],
                "summary": "Creates new content on the specified workspace from .pbix, .json, Excel, Rdl, or file path in OneDrive for Business.",
                "description": "<br/>**Required scope**: Dataset.ReadWrite.All <br/>To set the permissions scope, see [Register an app](https://docs.microsoft.com/power-bi/developer/register-app). <h3>Notes</h3><ul><li>To import a file, request Headers should include **Content-Type: multipart/form-data** with the file [encoded as form data](https://www.w3.org/TR/html401/interact/forms.html) in the request body </li><li>To import from OneDrive for Business, request Headers should include **Content-Type: application/json** with [ImportInfo](/rest/api/power-bi/imports/postimportingroup#importinfo) in the request body.</li><li>To import large .pbix files between 1 GB and 10 GB see [Create Temporary Upload Location In Group](/rest/api/power-bi/imports/createtemporaryuploadlocationingroup), supported only for workspaces on premium capacity.</li><li>To create a dataflow from a model.json, specify the parameter datasetDisplayName as described below.</li></ul>",
                "operationId": "Imports_PostImportInGroup",
                "consumes": [
                    "application/json",
                    "multipart/form-data"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "groupId",
                        "in": "path",
                        "required": true,
                        "description": "The workspace id",
                        "type": "string",
                        "format": "uuid"
                    },
                    {
                        "name": "datasetDisplayName",
                        "in": "query",
                        "required": true,
                        "description": "The display name of the dataset should include file extension. Not supported when importing from OneDrive for Business. For importing or creating dataflows, this parameter should be hardcoded to model.json.",
                        "type": "string"
                    },
                    {
                        "name": "nameConflict",
                        "in": "query",
                        "required": false,
                        "description": "Determines what to do if a dataset with the same name already exists. Default value is 'Ignore'.<br/>Only Abort and Overwrite are supported with Rdl files.<br/>Only Abort and GenerateUniqueName are supported with dataflow model.json files.",
                        "type": "string",
                        "enum": [
                            "Ignore",
                            "Abort",
                            "Overwrite",
                            "CreateOrOverwrite",
                            "GenerateUniqueName"
                        ],
                        "x-ms-enum": {
                            "name": "ImportConflictHandlerMode",
                            "modelAsExtensible": true,
                            "values": [
                                {
                                    "value": "Ignore",
                                    "description": "If dataset with the same name already exists, Import operation will create a new dataset with the same name."
                                },
                                {
                                    "value": "Abort",
                                    "description": "If dataset or dataflow with the same name already exists, Import operation will be aborted."
                                },
                                {
                                    "value": "Overwrite",
                                    "description": "If dataset with the same name already exists, Import operation will replace the existing dataset with the new one.<br/>Import operation will fail if there is no conflict or if there are more than one datasets with the same name."
                                },
                                {
                                    "value": "CreateOrOverwrite",
                                    "description": "If dataset with the same name already exists, Import operation will replace the existing dataset with the new one.<br/>Import operation will fail if there are more than one datasets with the same name."
                                },
                                {
                                    "value": "GenerateUniqueName",
                                    "description": "If a dataflow with the same name already exists, Import operation will generate a new unique name for the dataflow."
                                }
                            ]
                        }
                    },
                    {
                        "name": "skipReport",
                        "in": "query",
                        "required": false,
                        "description": "Determines whether to skip report import, if specified value must be 'true'. Only supported for PBIX files.",
                        "type": "boolean"
                    },
                    {
                        "name": "importInfo",
                        "in": "body",
                        "description": "The import to post",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/ImportInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/Import"
                        }
                    },
                    "202": {
                        "description": "Accepted",
                        "schema": {
                            "$ref": "#/definitions/Import"
                        }
                    }
                },

 

 

 

Thanks in advance.

 

Tom.

1 REPLY 1
v-diye-msft
Community Support
Community Support

Hi @Tom-P 

 

Sorry I can't repro this issue, please kindly raise it to the support team for better advice:

https://powerbi.microsoft.com/en-us/support/ 

 

You might check out this example of how to call the export/import endpoints in PowerShell: 

https://github.com/Azure-Samples/powerbi-powershell/blob/master/copyWorkspace.ps1

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.