Skip to content

Invoke-MgGraphRequest only supports relative URI when method is GET #950

@psignoret

Description

@psignoret

The code which prepends the scheme and host to the request URI is only executed when the method is GET.

Repro:

Invoke-MgGraphRequest `
    -Method POST `
    -Uri "/beta/directoryObjects/getByIds" `
    -Body @{ "ids" = @([Guid]::NewGuid().ToString()); "types" = @("user") }
Invoke-MgGraphRequest : This operation is not supported for a relative URI.
At line:1 char:1
+ Invoke-MgGraphRequest -Method POST -Uri "/beta/directoryObjects/getBy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-MgGraphRequest], InvalidOperationException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.InvokeMgGraphRequest

This issue is mentioned in passing in #887, but I think it's deserves a separate issue, as the root cause appears to be unrelated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions