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

Invoke-RestMethod doesn't properly handle JSON object conversion for APIs that return varying casings of the same spellings #21378

Closed
5 tasks done
nkasco opened this issue Mar 26, 2024 · 2 comments

Comments

@nkasco
Copy link

nkasco commented Mar 26, 2024

Prerequisites

Steps to reproduce

See #3705 as it is essentially the same issue, just in this case Invoke-RestMethod spits out a string instead of an object simply due to the result containing multiple variations of the same spelling (but different spelling casings)

Expected behavior

Typical API results from Invoke-RestMethod, objects, not strings.

Actual behavior

Invoke-RestMethod returns a string that is not converted from JSON, even though the output is indeed valid JSON.

Error details

ConvertFrom-JSON : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys <Key> and <KEY>. Please use the -AsHashTable switch instead.

Using -AsHashTable does work, but this functionality should be integrated with Invoke-RestMethod to avoid entirely.

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@nkasco nkasco added the Needs-Triage The issue is new and needs to be triaged by a work group. label Mar 26, 2024
@nkasco
Copy link
Author

nkasco commented Mar 26, 2024

Just realized this is a duplicate of #19378, closing and we can continue the conversation there.

@nkasco nkasco closed this as completed Mar 26, 2024
Copy link
Contributor

microsoft-github-policy-service bot commented Mar 26, 2024

📣 Hey @nkasco, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant