We have tried with the -ContentType “Application/Json; Charset=UTF8” but then PSU complains, that the parameter UserMessage is not missing on the client.
Both the data in DebuggingMessage.txt file and the return data from New-PSUApiResponse are showing the incorrect value.
We use English in all our UIs and documentation, but the API will be used to update peoples first and last name - so we need to be able to use the specialized characters.
Does anyone have a working solution, on how to get this working?
The one i used to create this post, are running:
API: pwsh 7.3.4 single process
Client: pwsh 7.3.4
This is my API:
param(
[Parameter(Mandatory = $true)]
[string]
$UserMessage
)
"á" #-->This is always working as expected
New-PSUApiResponse -Body "$UserMessage" -StatusCode 200 #--> This only works if the client is using ([System.Text.Encoding]::UTF8.GetBytes($Data))
This is from my client:
$Data = @{
UserMessage = "Ø"
} | ConvertTo-Json
#This seems to be working
Invoke-RestMethod http://192.168.2.26:5000/test/api123 -Method POST -Body ([System.Text.Encoding]::UTF8.GetBytes($Data)) -AllowUnencryptedAuthentication -SkipCertificateCheck -ContentType 'application/json'
#This is not working
Invoke-RestMethod http://192.168.2.26:5000/test/api123 -Method POST -Body $Data -AllowUnencryptedAuthentication -SkipCertificateCheck -ContentType 'application/json'
we have an endpoint for posting mail, running in the 7.3.1 Agent environment
I tried playing around with the Content-Type and Content-Encoding headers without luck, if I Out-File the incoming $Body, it keeps ending up wrong without the workaround