fix: SAC ingest UTF-8 JSON body for Cyrillic (1.2.8-SAC)

Invoke-WebRequest now posts application/json; charset=utf-8 bytes

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-28 10:05:49 +10:00
parent 71cb1fa9b6
commit 6c86e172b9
3 changed files with 12 additions and 6 deletions
+10 -4
View File
@@ -4,9 +4,14 @@
.DESCRIPTION
Dot-source после login_monitor.settings.ps1 и функции Write-Log.
Ожидает: $UseSAC, $SacUrl, $SacApiKey, $ScriptVersion, $script:InstallRoot.
Release: 1.2.7-SAC (ingest HTTP 201/409/202).
Release: 1.2.8-SAC (ingest UTF-8 body for Cyrillic summary/details).
#>
function Get-SacUtf8Bytes {
param([Parameter(Mandatory = $true)][string]$Text)
return (New-Object System.Text.UTF8Encoding $false).GetBytes($Text)
}
function Write-SacLog {
param([string]$Message)
if (Get-Command Write-Log -ErrorAction SilentlyContinue) {
@@ -221,11 +226,12 @@ function Invoke-SacPostPayload {
try {
Invoke-SacTlsPrep
$headers = @{
Authorization = "Bearer $SacApiKey"
'Content-Type' = 'application/json'
Authorization = "Bearer $SacApiKey"
'Content-Type' = 'application/json; charset=utf-8'
'Idempotency-Key' = $eventId
}
$resp = Invoke-WebRequest -Uri $ingest -Method Post -Headers $headers -Body $JsonBody -UseBasicParsing -TimeoutSec $timeout
$bodyBytes = Get-SacUtf8Bytes -Text $JsonBody
$resp = Invoke-WebRequest -Uri $ingest -Method Post -Headers $headers -Body $bodyBytes -UseBasicParsing -TimeoutSec $timeout
if ($resp.StatusCode -in 201, 409, 202) {
Remove-SacSpoolFile -EventId $eventId
Reset-SacFailCount