Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Change Request] Invoke-PnPGraphMethod -AdditionalHeaders does not accept a hashtable #4040

Open
1 of 6 tasks
joshtransient opened this issue Jun 21, 2024 · 1 comment
Open
1 of 6 tasks
Assignees
Labels
enhancement New feature or request v3

Comments

@joshtransient
Copy link

Reporting an Issue or Missing Feature

I'm considering this an issue (not a feature request) since I'd expect others to also file this as a bug. I'm all for using generics for type safety, but...come on. I shouldn't have to cast a whole new dictionary on a separate line just to use this argument.

Expected behavior

The -AdditionalHeaders argument of Invoke-PnPGraphMethod should accept a hashtable the sake of simplicity and readability.

Actual behavior

When using a hashtable in the -AdditionalHeaders argument of Invoke-PnPGraphMethod, I receive the error message:

Cannot bind parameter 'AdditionalHeaders'. Cannot convert the "System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type "System.Collections.Generic.IDictionary`2[System.String,System.String]".

The workaround is:

$dict = [System.Collections.Generic.Dictionary[string,string]]::new()
$dict.Add('header','value')
$dict.Add('header2','value2')
Invoke-PnPGraphMethod ... -AdditionalHeaders $dict

Steps to reproduce behavior

Sample command (Connected to PnP with -Interactive or an app registration with User.Read.All):

Invoke-PnPGraphMethod -Method Get -Url 'https://graph.microsoft.com/v1.0/users?$select=displayName&$filter=assignedLicenses/$count ne 0&$count=true' -AdditionalHeaders @{ ConsistencyLevel = 'eventual' }

What is the version of the Cmdlet module you are running?

2.4.0

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@joshtransient joshtransient added the bug Something isn't working label Jun 21, 2024
@gautamdsheth
Copy link
Collaborator

@joshtransient - appreciate your feedback. We will update this in v3 to a hashtable.

It is not a bug, will consider this as enhancement though. Can't change it in current versions, 2.x, as it will be a breaking change.

@gautamdsheth gautamdsheth self-assigned this Jun 26, 2024
@gautamdsheth gautamdsheth added enhancement New feature or request v3 and removed bug Something isn't working labels Jun 26, 2024
@gautamdsheth gautamdsheth changed the title [BUG] Invoke-PnPGraphMethod -AdditionalHeaders does not accept a hashtable [Change Request] Invoke-PnPGraphMethod -AdditionalHeaders does not accept a hashtable Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v3
Projects
None yet
Development

No branches or pull requests

2 participants