As already mentioned by @larsks the filenames inserted via {}
into the curl
are apparently interpreted as host names and therefore generating that error.
It works if you put the {}
into the text property of the message, which will then include the found filename in the message to the Slack webhook. I guess it would also make sense to not only send a message, but also include the name of that file in that message.
find . -mtime -1 -exec curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World! {}"}' https://hooks.slack.com/services/FooBar \;
Or if you don't want to show the found filenames on Slack you can just omit the {}
altogether:
find . -mtime -1 -exec curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/FooBar \;
Finally, I would assume you do not want to send a message for the "." directory, so you need to exclude it: (from here)
find . -mtime -1 -not -path "." -exec curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/Foobar \;