How to implement the post request interface when the timed task calls the curl method

created at 03-31-2022 views: 14

problem

Use crontab -e to add a new scheduled task, as follows:

*/1 * * * * /usr/bin/curl http://xxxx.com/api/sendmsg

Later, it was found that the above is a get request, but the post interface cannot be requested, so I tried several methods in the background, and found that the interface can be called correctly as follows,

solution

crontab executes the request for the interface every one minute.

*/1 * * * * /usr/bin/curl http://xxxx.com/api/sendmsg -X POST

It is safer to use the post method for the interface! Hope to give you some help!

created at:03-31-2022
edited at: 03-31-2022: