0

I want to make a cURL request every 12 hours and trigger the request with a cronjob. Unfortunately I'm a total newbie in cURL and cronjobs.

This is the request I want to make:

curl --location --request POST 'https://example.com/wp-admin/admin-ajax.php' \
--form 'action="algolia_re_index"' \
--form 'index_id="searchable_posts"' \
--form 'p="1"'

The request should be triggered by a cronjob via EasyCron. I need to add simple URLs there.

So I tried this:

curl -s "https://example.com/wp-admin/admin-ajax.php' \ --form 'action="algolia_re_index"' \ --form 'index_id="searchable_posts"' \ --form 'p="1"'"

But that's not working.

I don't understand how I add the parameters to the URL. Do I need to add something on my server/site?

Here's the article about the topic.

Cray
  • 135
  • 5
  • 1
    Remove the backslashes. They escape the newline and are just there to make the command multiline to make it better readable. – Gerald Schneider Oct 12 '22 at 09:57
  • I tried this: `https://example.com/wp-admin/admin-ajax.php&action=algolia_re_index&index_id=searchable_posts&p=1` but the cronjob fails because of an 404 error – Cray Oct 12 '22 at 10:07
  • 1
    Well, that's a default WordPress URL. If you get a 404 your problem is on the server side, not on the curl side. – Gerald Schneider Oct 12 '22 at 10:09
  • Okay @GeraldSchneider, I will check that – Cray Oct 12 '22 at 11:55

0 Answers0