PowerShell – Non latin language with REST

#HTTP Headers building
$ContentType= 'application/json; charset=utf-8'
$headers = @{"tenant-code" = $tenantAPIKey; "Authorization"= $BasicCredentials}  

$Message = @{
  MessageBody = "Привет от Камиллы"
  MessageType = "String"
}

#Convert to JSON Depth at 10 ensure correct convertion for long text
$MessageInJSON = $Message | ConvertTo-Json -Depth 10 

#Convert Message to UTF-8 encoding
$Body = [System.Text.Encoding]::UTf8.GetBytes($MessageInJSON)

#Sending Message using Rest
$Output = Invoke-RestMethod -Method Post -Credential $Credentials -Uri $URI -Body $Body -ContentType $ContentType -Headers $headers
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s