Skip to content

Wrong encode in Invoke-RestMethod -Body (problem with cyrilic symbols) #7618

@FreZZZeR-I

Description

@FreZZZeR-I

Steps to reproduce

Invoke-RestMethod -Uri $URI -Method Put -ContentType 'application/json' -Body '{"jsonrpc":"2.0","method":"get.object","params":{"latname":"testing","cyrname":"проверка"}}'

Expected behavior

http request json

{"jsonrpc":"2.0","method":"get.object","params":{"latname":"testing","cyrname":"проверка"}}

Actual behavior

http request json

{"jsonrpc":"2.0","method":"get.object","params":{"latname":"testing","cyrname":"????????"}}

Environment data

Name Value


PSVersion 6.1.0-rc.1
PSEdition Core
GitCommitId 6.1.0-rc.1
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Description

It works good if -InFile Parameter is used

Invoke-RestMethod -Uri $URI -Method Put -ContentType 'application/json' -InFile $FilePath 

File must be encoded in UTF-8 with no BOM

I think cmdlet encodes body to ASCII
In PS 5.1, 6.0 the same bug is.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions