Hi-
I have a Elastic Search Rest API to query along with range condition, which would need to be executed thru Powershell using Invoke-RestMethod command, but it fails. It works alright using Curl.
Curl command:
curl -u User:Password -X GET "localhost:9200/test_data-*/_count" -H 'Content-Type: application/json' -d'
{
"query": {
"range" : {
"@timestamp" : {
"gte" : "now-15m/m",
"lte" : "now"
}
}
}
}
'
I have written the below powershell script:
$response = Invoke-RestMethod "http://localhost:9200/test_data-*/_count" -Method Get -Headers @{Authorization=("Basic {0}" -f $authHeaderValue)}
-Body "{
"query": {
"range" : {
"@timestamp" : {
"gte" : "now-15m/m",
"lte" : "now"
}
}
}
}"
I get this error:
Invoke-RestMethod : Cannot send a content-body with this verb-type. At line:1 char:13
Could someone help me how do I make a GET request with body block in Powershell? Thanks !
