API with Powershell
Posted: Fri Mar 13, 2026 11:59 am
Could someone help me out?
and this is what I receive,
{
"errno": 40256,
"msg": "Please close and reopen this page illegal signature"
}
Any idea? Thanks
Code: Select all
$deviceSN = "60KBxxxxxxx"
$token = "xxxxx-6b84-4b8b-xxxx-xxxxxxxx"
$timestamp = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$path = "/op/v1/device/real/query"
$dataToSign = "$path`r`n$token`r`n$timestamp"
$signature = [BitConverter]::ToString([System.Security.Cryptography.MD5]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($dataToSign))).Replace("-", "").ToLower()
$headers = @{
'Token' = $token
'Lang' = 'en'
'Timezone' = 'Australia/Sydney'
'Timestamp' = $timestamp
'Content-Type' = 'application/json'
'Signature' = $signature
}
$body = @{
deviceSN = $deviceSN
} | ConvertTo-Json -Compress
try {
$response = Invoke-RestMethod -Uri "https://www.foxesscloud.com/op/v0/device/real/query" -Method Post -Headers $headers -Body $body -ContentType "application/json"
Write-Output "$($response | ConvertTo-Json)"
} catch {
Write-Output "$($_.Exception.Message)"
if ($_.Exception.Response) {
$responseStream = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($responseStream)
$responseText = $reader.ReadToEnd()
Write-Output "$responseText"
} else {
Write-Output ""
}
} {
"errno": 40256,
"msg": "Please close and reopen this page illegal signature"
}
Any idea? Thanks