I am trying to send a JSON request to a webhook api, as per the document Webhook connector and action | Kibana Guide [8.14] | Elastic. But I am getting the below error.
Details:
[415] UNSUPPORTED MEDIA TYPE: Did not attempt to load JSON data because the request Content-Type was not 'application/json'.
The endpoint is responding for the post, and I have tested with below.
$url = " https://url/webhook/"
$headers = @{
"Authorization" = "adkfjalsdjfkasdgkjasdkfj"
# Add other headers here as needed
}
# Create an object for the JSON body
$body = @{
"title" = "Disk Space alert from powershell"
"description" = "Your Description Here"
}
# Convert the body object to a JSON string
$jsonBody = $body | ConvertTo-Json
# Use Invoke-WebRequest with the URL, headers, and body
$response = Invoke-WebRequest -Uri $url -Method Post -Headers $headers -Body $jsonBody -ContentType "application/json"
$responseObject = $response.Content | ConvertFrom-Json
Write-Host "Title is :"$responseObject.title ---- I can able to print what im sending..