Forum Discussion

Cha74910's avatar
Cha74910
Copper Contributor
Jan 04, 2023

API to change the name of a dataflow

Hello,
I would like to be able to change the name of a dataflow using this API: https://learn.microsoft.com/en-us/rest/api/power-bi/dataflows/update-dataflow

 

Here is my code:

$body=@{
            name = "DTF TEST Pipeline 1.0.1"
        }

Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/8569358a-549c-466a-894c-de113f5c4fb1/dataflows/8774dad3-3f17-4444-b73b-b82cea0812b6" -Method Patch -Body $body

 

However when I run the command I get this error message:

Invoke-PowerBIRestMethod : Une ou plusieurs erreurs se sont produites.
Au caractère Ligne:12 : 1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
    + FullyQualifiedErrorId : Une ou plusieurs erreurs se sont produites.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
 
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
  "code": "BadRequest",
  "message": "Bad Request",
  "details": [
    {
      "message": "Unexpected character encountered while parsing value: S. Path '', line 0, position 0.",
      "target": "dataflowUpdateInformation"
    }
  ]
}
Au caractère Ligne:12 : 1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], Exception
    + FullyQualifiedErrorId : Encountered errors when invoking the command: {
  "code": "BadRequest",
  "message": "Bad Request",
  "details": [
    {
      "message": "Unexpected character encountered while parsing value: S. Path '', line 0, position 0.",
      "target": "dataflowUpdateInformation"
    }
  ]
},Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
  • AndySvints's avatar
    AndySvints
    Steel Contributor

    Hello Cha74910,

    It looks like that error that you are receiving is related to the Body parameter.

    Body parameter of Invoke-PowerBIRestMethod is Type of String and you are passing a HashTable into it.

    Try something like this:

    Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/8569358a-549c-466a-894c-de113f5c4fb1/dataflows/8774dad3-3f17-4444-b73b-b82cea0812b6" -Method Patch -Body $($body | ConvertTo-Json)

    Hope that helps.

Resources