1

I could get the Dataset from below code:

var client = new PowerBIClient(new Uri(_ApiUrl), _tokenCredentials);
var datasets = await client.Datasets.GetDatasetsAsync(new Guid(_workspaceId));

However, there is error when I run below code (datasets.Value.Count > 0):

await client.Datasets.UpdateRefreshScheduleAsync(new Guid(_workspaceId), datasets.Value[datasets.Value.Count - 1].Id, refreshSchedule);

Exception Error:

"Operation returned an invalid status code 'Forbidden'"


Supplement the API Permissions of PowerBI: enter image description here

2
  • Make sure your account has rights to do this, and also the app registration used has rights to do this (Dataset.ReadWrite.All). Commented May 29, 2020 at 11:38
  • Hi @AndreyNikolov, I supplemented API Permissions of PowerBI for your reference. Dataset.ReadWrite.All is granted already and Backend is using this PowerBI to access PowerBI resources. Please advise, thanks. Commented Jun 1, 2020 at 5:39

1 Answer 1

1

The delegated account through which the app is running / service principal should be added with full control to the dataset in addition to the app has permission at the Azure AD end.

Also, you can capture the server response to understand more on the error.

The Server response will have additional information on why the Service returned a Forbidden

Attached a sample output below :

enter image description here

The server response will be helping you more - especially the header with PowerBI error Info

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @sathya_vijayakumar-MSFT. After I granted privilege to ServicePrincipal in PowerBI console and using your suggested method ScheduleNotifyOption.NoNotification, it is okay to update RefreshSchedule now.
@DaiKeung, glad to know :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.