I'm trying to pass --data-raw options to a curl inside bash function, but I get option unknown error.
function api_call () {
local data="$5"
echo $(curl -L -X $1 "https://api.datadoghq.com/api/v1/monitor/$2" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: $3" \
-H "DD-APPLICATION-KEY: $4" \
$data)
}
I call it with
api_call "PUT" $monitor_id $DATADOG_API_KEY $DATADOG_APP_KEY $query
my query value is
query="--data-raw '{"query":"sum(last_1m):avg:application.health{application.health:healthy,c_name:nname,!source:service-full-1} by {source}.as_count() < 60"\}')"
but it doesn't matter what I put in data, it doesn't get accepted when calling the function. It works as intended if I simply do a curl.
What am I missing? thanks!