Forum in maintenance, we will back soon 🙂
ERROR with Build a Backend With No Code Automation Tool “Make”
hi Hassan i've gotten through to the end of this video but keep getting the below 'oops page cant be found'.
I tested the make.com webhook in url and it works fine.
Ive copied and pasted your code into the wp snippet, and changed the webhook URL to my make.com one.'
I then entered my wordpress custom endpoint address into the url. but get the below. for the URL, I am using:
https://my-wordpress-domain-name/wp-json/custom/v1/make-webhook?topic=happy
@paddy what is your "my-wordpress-domain-name" actually. We can review the browser errors from our side.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@paddy It gives me a login first message. I'm willing to discuss this privately on my Slack channel; see my signature.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@sergiousadvisor Hi Earnie I think you are looking at a different page. Did you try this one? https://aiworkflowpro.io/wp-json/custom/v1/make-webhook?topic=happy
@paddy yes, I get the Oops. The page not being found is due to the fact that your system isn't providing the endpoint for the URL.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@admin Hi Hasan please see below
// Add a custom endpoint 'make-webhook' add_action('rest_api_init', function () { register_rest_route('custom/v1', '/make-webhook/', array( 'methods' => 'GET', // Adjust methods as needed (GET, POST, etc.) 'callback' => 'call_make_webhook', // Callback function to handle the request 'args' => array( 'topic' => array( 'required' => true, 'validate_callback' => function ($param, $request, $key) { return is_string($param); }, ), ), )); }); // Callback function to call the webhook function call_make_webhook($data) { // Retrieve the 'topic' parameter from the request data $topic = $data['topic']; // Construct the webhook URL with the topic parameter $webhook_url = 'https://hook.us1.make.com/mywebhooknormallyhere?topic=' . urlencode($topic); // Set the timeout duration in seconds $timeout = 30; // Prepare arguments for the HTTP GET request $args = array( 'timeout' => $timeout, ); // Perform the HTTP GET request to the webhook URL with timeout $response = wp_remote_get($webhook_url, $args); // Check if the request was successful if (is_wp_error($response)) { $error_message = $response->get_error_message(); error_log('HTTP Error: ' . $error_message); return new WP_Error('webhook_error', 'Error connecting to webhook'); } else { // Return the body content of the response return wp_remote_retrieve_body($response); } }
The problem here is related to caching. When I disabled caching, API endpoints worked. so you may need to exclude the custom API endpoint paths from caching
thanks for checking on that Hasan. Where can I exclude the custom endpoint paths from caching?
@paddy I see you are using litespeed, there must be a place to exclude URLs from cache.
something like:
Litespeed Cache sidebar menu > page optimization > tuning, list your url in “URI Excludes” box.
let me know if you cant find it. I can login to your site again and check.
which hosting service you are using?
and did you install litespeed plugin, or you got it with the hosting?
@admin Hi Hasan Lightspeed came with the hostinger subscription.
I found the location as you described. So which URL do I need to list in the 'URI Excludes' box? this one?
https://aiworkflowpro.io/wp-json/custom/v1/make-webhook?topic=aiautomation
so now that the wordpress php snippet is connecting to make and the webhook works in the browser, how do I connect the snippet to a front end UI?