-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
I totally have no idea what's happening here. Hope someone here can help me. That makes no sense and its frustrating...
I tried to reach the text translation API in PowerShell. This are my Global Variables:
$TranslatorKey = "e54902*******" # You need a valid key for Microsoft Translator
$global:BaseUri = "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0"
$global:Headers = @{
'Ocp-Apim-Subscription-Key' = $translatorKey
'Ocp-Apim-Subscription-Region' = 'germanywestcentral' # added (change if needed)
'Content-type' = 'application/json; charset=UTF-8'
}
When i use the Text directly inside my Code it works:
$LanguageCode = "de"
$textJson = @{
"Text" = "Users may see some meetings scheduled in Mexico time zones are displaying with the incorrect time."
} | ConvertTo-Json
$Body = "[$textJson]"
$Uri = "$($global:BaseUri)&to=$($LanguageCode)"
$Status = Invoke-RestMethod -Method Post -Uri $uri -Headers $global: headers -Body $Body
But if i want to use a Variable with the Text inside, it throws the Error in the Title:
$temp = "Users may see some meetings scheduled in Mexico time zones are displaying with the incorrect time."
$LanguageCode = "de"
$textJson = @{
"Text" = $temp
} | ConvertTo-Json
$Body = "[$textJson]"
Ive checked absolutely everything and have no idea what's the difference. I really Hope someone can help me.
Metadata
Metadata
Assignees
Labels
No labels