I am making an API call to a system that is supposed to return a list of names.
$headers=@{}
$headers.Add("Accept", "application/json;charset=UTF-8")
$headers.Add("Authorization", "secretkey")
$people= Invoke-RestMethod -Uri 'https://someAPI' -Method GET -Headers $headers
$people.fullname #Expecting names with åäö, but does not work.
When I use the API call on the developers website, it shows the people's names with ÅÄÖ , for instance, "Anna Ängberg" , but when I run the Invoke-RestMethod command in Powershell, the name becomes "Anna ängberg". Clearly an encoding issue.
How do I modify the script to force the encoding? There is no "encoding" flag to Invoke-RestMethod. I do not want to use Invoke-WebRequest because that does not return the result as a powershell object that I want to work with.
I have tried adding to Invoke-Restmethod the following:
-ContentType "application/json;charset=UTF-8"
-ContentType "application/json;charset=UTF-16"
And both forms in the Accept Header as well