You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invoke-RestMethod/Invoke-WebRequest should set charset=utf-8 for application/json by default #10971
Recently had an issue trying to use a GitHub API when I put emojis in the POST body:
$body=ConvertFrom-Json@{
tag_name="tag"name="demo"body="I like 🐛s"draft=$trueprerelease=$true
}
$uri="https://api.github.com/repos/me/bughunter/releases"$headers=@{
GitHubToken=$myTokenAccept="application/vnd.github.v3+json"
}
Invoke-RestMethod-Method Post -Uri $uri-Body $body-Headers $headers
Sending this published a draft with the description:
I like ??s
Took me a while to work out I needed -ContentType "application/json; charset=utf-8", which is fine. Except everything else defaulted (as expected) to UTF-8, so I assumed this would too.
Worth noting that this is probably classable as a breaking change, but if we're always converting upper ASCII to ? then I'm not sure what we'd be breaking.
Given that our console and output encoding default to utf-8, it seems like the webcmdlets should also follow with utf-8 as default charset unless overridden. cc Mark Kraus (@markekraus)
he852100 I edited your example removing sensitive information. If you're referring to the first couple of characters, it appears to be a malformed BOM. How was that document saved to live.com? Was it UTF-8 encoded with a BOM?
That's a UTF8 BOM encoded as ASCII or other non- Saw it take down a production service a few jobs ago when an xml feed encoded in UTF-8 decided to also send the optional BOM.
Activity
rjmholt commentedon Nov 1, 2019
Worth noting that this is probably classable as a breaking change, but if we're always converting upper ASCII to
?then I'm not sure what we'd be breaking.SteveL-MSFT commentedon Nov 1, 2019
Given that our console and output encoding default to utf-8, it seems like the webcmdlets should also follow with utf-8 as default charset unless overridden. cc Mark Kraus (@markekraus)
he852100 commentedon Nov 3, 2019
Xml is not recognized
SteveL-MSFT commentedon Nov 4, 2019
he852100 I edited your example removing sensitive information. If you're referring to the first couple of characters, it appears to be a malformed BOM. How was that document saved to live.com? Was it UTF-8 encoded with a BOM?
he852100 commentedon Nov 5, 2019
Steve Lee (@SteveL-MSFT) It's the data of the website.I didn't create it.
CodeShane commentedon May 11, 2021
That's a UTF8 BOM encoded as ASCII or other non- Saw it take down a production service a few jobs ago when an xml feed encoded in UTF-8 decided to also send the optional BOM.
U+FEFF Byte Order Mark