status=$(curl -i -s -H "Authorization: token abc123" https://www.some_url.com | awk 'NR==18')
if [ "$status" != 200 ]; then
echo "$status"
fi
The above code is working and echo is printing the output in my console.
But when I use discord webhook, it doesn't send message there and throws following error: {"code": 50109, "message": "The request body contains invalid JSON."}
webhook=https://discord.com/api/webhooks/abc123
status=$(curl -i -s -H "Authorization: token abc123" https://www.some_url.com | awk 'NR==18')
if [ "$status" != 200 ]; then
curl -H "Content-Type: application/json" -X POST -d '{"content":"'"$status"'"}' $webhook
fi
I can send a normal message through webhook but not this curl output. The output is suppose to be HTML error message.
Even if I change awk 'NR==18' to awk 'NR==1', it's not sending even the one line output which is suppose to be something like: HTTP/1.1 401 Unauthorized