Forum Discussion

gtzanakis's avatar
gtzanakis
Advocate I
2 years ago
Solved

API DataflowUnauthorizedError when trying to update a Dataflow although all permissions are set

Dear all,

 

I am using the following script trying to update the computeEngineBehavior of a Dataflow of mine.

 

 

#!/bin/bash

# Obtain access token
echo "Requesting access token..."
TOKEN_RESPONSE=$(curl -s -X POST \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi" \
  "https://login.microsoftonline.com/$TENANT_ID/oauth2/token")

# Extract access token from response
ACCESS_TOKEN=$(echo $TOKEN_RESPONSE | jq -r '.access_token')

if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" == "null" ]; then
  echo "Failed to obtain access token. Please check your credentials."
  exit 1
fi

# Update the Dataflow
echo "Sending request..."
RESPONSE=$(curl -s -X PATCH \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"computeEngineBehavior": "computeDisabled"}' \
  "https://api.powerbi.com/v1.0/myorg/groups/$WORKSPACE_ID/dataflows/$DATAFLOW_ID")

echo "Response: $RESPONSE"

 

 

When I run it, I'm getting the following error:

 

{"error":{"code":"DataflowUnauthorizedError","message":"You do not have permissions to manage this dataflow."}}

 

 

However:

 

1. I have double-checked all environmental variables regarding the workspace & dataflow IDs, secrets, etc.

2. My Service Principal has Admin access to this workspace

3. My Service Principal has "Dataflow.ReadWrite.All" (and, in fact, almost every permission under the sun) in its API permissions section

4. If I modify my script to POST a refresh request, it works great

5. I can perform this type of request with my personal credentials when using the "Try it" button in the corresponding API documentation page.

 

Can anybody explain to me why I'm getting this error and how I can fix it?

 

 

2 Replies