skip to Main Content

This is the example Request body provided by Microsoft to disable a PowerBi schedule refresh via the Rest API

{
  "value": {
    "enabled": false
  }
}

When I call the API, using a service principal, in ADF, with the same request body I get the following error.

{"error":{"code":"InvalidRequest","message":"Invalid NotifyOption
value ‘MailOnFailure’ for app only owner requests"}}

If I amend the Body like so,

{
  "value": {
    "enabled": false,
   "ScheduleNotifyOption":"NoNotification"
  }
}

I get the following error

{"error":{"code":"BadRequest","message":"Bad
Request","details":[{"message":"Value cannot be null.rnParameter
name: nullableType","target":"datasetModelRefreshSchedule"}]}}

The notes on the API state that "A request that disables the refresh schedule should contain no other changes."

enter image description here

Here’s the web activity code

{
    "name": "Disable dataset refresh",
    "type": "WebActivity",
    "dependsOn": [
        {
            "activity": "Takeover dataset",
            "dependencyConditions": [
                "Succeeded"
            ]
        }
    ],
    "policy": {
        "timeout": "0.00:10:00",
        "retry": 5,
        "retryIntervalInSeconds": 30,
        "secureOutput": false,
        "secureInput": false
    },
    "userProperties": [],
    "typeProperties": {
        "method": "PATCH",
        "headers": {
            "Authorization": {
                "value": "@concat(n    string(activity('Get AAD Token').output.token_type)n    , ' 'n    , string(activity('Get AAD Token').output.access_token)n    )",
                "type": "Expression"
            }
        },
        "url": {
            "value": "https://api.powerbi.com/v1.0/myorg/groups/@{pipeline().parameters.PBIWorkspaceId}/datasets/@{pipeline().parameters.PBIDatasetId}/refreshSchedule",
            "type": "Expression"
        },
        "body": {
            "value": {
                "enabled": false
            }
        },
        "authentication": {
            "type": "ServicePrincipal",
            "userTenant": {
                "value": "@pipeline().globalParameters.TenantId",
                "type": "Expression"
            },
            "username": {
                "value": "@pipeline().parameters.SP_ClientId",
                "type": "Expression"
            },
            "resource": "https://analysis.windows.net/powerbi/api",
            "password": {
                "type": "AzureKeyVaultSecret",
                "store": {
                    "referenceName": "LS_KV",
                    "type": "LinkedServiceReference",
                    "parameters": {
                        "baseUrl": {
                            "value": "@pipeline().globalParameters.KeyVaultUrl",
                            "type": "Expression"
                        }
                    }
                },
                "secretName": "xxx"
            }
        }
    }
}

How do I correct this?

2

Answers


  1. Chosen as BEST ANSWER

    Resolved this.

    What you need is another web activity before the disable the scheduled refresh one to first disable the notification.

    Here's the json body for the web activity to disable the notification

    {
        "value":{
            "NotifyOption":"NoNotification"
        }
    }
    

    And then the json body for the web activity to disable the scheduled refresh

    {
        "value":{
            "enabled":false
        }
    }
    

    enter image description here


  2. {"error":{"code":"InvalidRequest","message":"Invalid NotifyOption value ‘MailOnFailure’ for app only owner requests"}}

    You’re encountering an issue with the Power BI REST API when using a service principal in Azure Data Factory (ADF). The error message indicates an issue with the "NotifyOption" value being set to ‘MailOnFailure‘ which is not valid for app-only owner requests.

    service principals only support the NoNotification value for the "ScheduleNotifyOption" when terminating a scheduled refresh. This means that you cannot use the ‘MailOnFailure’ option when authenticating with a service principal; it should either be omitted or set to ‘NoNotification’.

    You adjust and try the "NotifyOption" in your request body to comply with the supported values for service principals.

    Reference: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-refresh-schedule-in-group

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search