Open NancyAb opened 6 years ago
I am getting a similar error:
Invoke-RestMethod : A positional parameter cannot be found that accepts argument 'â€Headers
System.Collections.Hashtable â€Method'.
At \PowerBI_Powershell_Script\Updated_Powershell_Script.ps1:119 char:1
+ Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST – ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
@NancyAb
I was getting the same error and these updates made my code work:
$authHeader = @{ Authorization=$token.CreateAuthorizationHeader() Content='application/json' }
and I believe the sample code mixes long and short dashes which was giving me an error as well so here is the modified code for that:
Invoke-RestMethod -Uri $uri -Headers $authHeader -Method POST -Verbose
Thanks so much. I will have a look. Nancy.
Hi,
I had the same issue and got an error with BrightKnight6 code too, but adding single quotes around Authorization and Content seemed to do the trick. So the key difference between the original and this is Content instead of Content-Type. I'm a newbie to all the concepts here so can't really explain why.
This is what I ended up with:
$authHeader = @{ 'Authorization'=$token.CreateAuthorizationHeader() 'Content'='application/json' }
Scott
I consistently receive the error below and my dataset does not refresh, any help would be appreciated. " Invoke-RestMethod : The remote server returned an error: (400) Bad Request. At line:85 char:1
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
VERBOSE: GET https://api.powerbi.com/v1.0/myorg/datasets/$datasetId/refreshes with 0-byte payload
HI All,
I am also getting : PS C:\temp> .\sample.ps1 [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult System.Collections.Hashtable Invoke-RestMethod : A positional parameter cannot be found that accepts argument 'â?Headers System.Collections.Hashtable â?Method'. At C:\temp\sample.ps1:78 char:1
+ CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand](url)
I tried all changes mentioned above but nothing worked. Please help
I'm also getting similar error:
Invoke-RestMethod : A positional parameter cannot be found that accepts argument 'â€Headers System.Collections.Hashtable â€Method'. At C:\Users\toneyc\Downloads\copyWorkspace.ps1:76 char:16
+ CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
HI All,
I am also getting : PS C:\temp> .\sample.ps1 [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult System.Collections.Hashtable Invoke-RestMethod : A positional parameter cannot be found that accepts argument 'â?Headers System.Collections.Hashtable â?Method'. At C:\temp\sample.ps1:78 char:1
- Invoke-RestMethod -Uri $uri â?"Headers $authHeader â?"Method POST â?"Verbose
+ CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand](url)
I tried all changes mentioned above but nothing worked. Please help
You need to save you code to file that is not UTC. More than likely you copied code from a webpage and it include special characters that need to be removed.
You can always delete the problem line and retype it manually.
+1
Tried all suggestions and nothing worked.
@nickodemis99 The file was download via git, not a web browser
Hi,
I have PowerBI setup with a gateway and have been able to refresh the datasource using the MS tools.
I have customized the ps1 program with my company's settings and have installed the PowerShell tools.
When I run the manageRefresh.ps1 command, I get the errors:
Any ideas? Thanks in advance for looking. Nancy.