Share via


Invoke-PowerBIRestMethod -Method Post failing

Question

Monday, October 15, 2018 4:48 PM

Hi, 

I'm new to PS. I'm trying to create script that will refresh some datasets through Power BI API. I have registered App in Active Directory and gave it almost every permissions possible for Power BI service (only missing ones are "Read and write all content in tenant" and "View all content in tenant").

If I put in my script -Method GET, everything is working and script will retrieve list of refreshes, but if I'm trying to do the same with -Method POST, script fails on some kind of write error.

$urlrefresh = "groups/$groupID/datasets/$datasetID/refreshes"

Invoke-PowerBIRestMethod -Url $urlrefresh  –Method GET

I'm assuming it must be some kind of permissions problem, but like I said, App is already having almost all of them.

Error message:

Invoke-PowerBIRestMethod : One or more errors occurred.
At line:2 char:1
+ Invoke-PowerBIRestMethod -Url $urlrefresh -Method Post –Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

All replies (2)

Monday, October 15, 2018 5:24 PM

From the docs:

*** The -Body parameter is required for the verbs POST, PUT, and PATCH. Before you run this command, make sure you log in using Connect-PowerBIServiceAccount***

\(ツ)_/


Tuesday, October 16, 2018 2:29 AM

Hi,

Thanks for your question.

I agree with jrv. You can check the microsoft document of "Invoke-PowerBIRestMethod" cmdlet.

Refer the link:

/en-us/powershell/module/microsoftpowerbimgmt.profile/invoke-powerbirestmethod?view=powerbi-ps

About Working with PowerShell in Power BI, you can learn something from the link below:

http://www.businessintelligenceinfo.com/business-intelligence/self-service-bi/working-with-powershell-in-power-bi

In REST, each HTTP verbs has its place and meaning.
For example,

  1. GET is to get the 'resource(s)' that is pointed to in the URL.
  2. POST is to instructure the backend to 'create' a resource of the 'type' pointed to in the URL. You can supplement the POST operation with parameters or additional data in the body of the POST call.

Best Regards,

Lee

Just do it.