Tom-P
Hola a todos,
Publiqué esto en el foro de servicio, ¡sin darme cuenta de que la discusión de la API debería estar aquí!
He seguido una serie de guías para conectarme a las API REST de PowerBI utilizando un conector personalizado en PowerAutomate / Flow y, en general, lo tengo funcionando bien … Ahora estoy usando con éxito flujos para actualizar parámetros, actualizar conjuntos de datos, etc.
En lo que fallé es en intentar duplicar un informe y un conjunto de datos, exportando e importando.
Estoy usando la arrogancia publicada aquí:
https://github.com/microsoft/PowerBI-CSharp/blob/master/sdk/swaggers/swagger.json
El flujo actualmente se ve así:
Exportar está usando esto:
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreportingroup
Esto es exitoso y si pongo el cuerpo de esto en una redacción para verificarlo, me da un archivo zip, que cuando se descarga y se le cambia el nombre a .pbix, se abre correctamente.
El resultado sin procesar de la acción de exportación es:
{"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]"}}
Luego estoy tratando de tomar el cuerpo de la exportación y usarlo con la función de importación a grupo POST:
https://docs.microsoft.com/en-us/rest/api/power-bi/imports/postimportingroup
Recibo este error con un código de estado 400:
{
"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"
}
Si hago clic en la «entrada» de esa acción, se muestra como:
{"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"}}
¿Alguna idea de lo que estoy haciendo mal? ¿Alguien ha logrado hacer esto con éxito que me pueda orientar en la dirección correcta? Para una fácil referencia, el código swagger para la acción de importación a grupo se encuentra a continuación:
"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"
}
}
},
Gracias por adelantado.
Tomás.
v-diye-msft
Hola @ Tom-P
Lo siento, no puedo reprochar este problema. Por favor, comuníqueselo al equipo de soporte para obtener un mejor consejo:
https://powerbi.microsoft.com/en-us/support/
Puede consultar este ejemplo de cómo llamar a los extremos de exportación / importación en PowerShell:
https://github.com/Azure-Samples/powerbi-powershell/blob/master/copyWorkspace.ps1