TheHiveDocs icon indicating copy to clipboard operation
TheHiveDocs copied to clipboard

alert API - Error: Invalid Json body for Alert.

Open shu172 opened this issue 6 years ago • 1 comments

Hi,

We've tried to add some alarms with IOCs via script using the API but keep getting "Error: Invalid Json body for Alert."

I've tried adding "-ContentType "application/json; charset=UFT-8"" which returns error 'UFT-8' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Parameter name: name"

Also tried UTF8 with same result. TheHive 4.0RC, script triggered on Win Server 2016

Any ideas what we do wrong?

Many thanks Luk

shu172 avatar Mar 12 '20 17:03 shu172

This works for me on Windows, no special encoding required.

    $headers = @{Authorization = "Bearer $thehiveKey"} 

    $alertBody = $alert | ConvertTo-Json

    Invoke-RestMethod -Method Post -Uri $uri -ContentType 'application/json' -Headers $headers -Body $alertBody
    

hkelley avatar Jan 11 '21 12:01 hkelley