I’m currently facing a challenge integrating a 3rd party API (Make.com) into my Wix site using HTTP functions and could use some guidance.
Overview:
I am trying to setup a workflow where:
A custom webhook in Make receives data.
Make processes this data and sends a response to my Wix site using an HTTP POST request.
My Wix site’s backend function is supposed to receive this POST request and process the data.
What I’ve Tried:
I’ve set up an HTTP function (responseHandler.web.js) in the backend section of my Wix site to handle incoming POST requests.
The function is designed to parse incoming JSON data, process it, and send back a response.
I’ve used Postman to simulate the POST requests to ensure the function receives and processes the data correctly.
Permissions for the HTTP function have been set to public (I hope I did it right…).
Issue:
Despite these configurations, every time Make tries to send data to the specified endpoint, I receive a 404 error indicating that the resource could not be found. This occurs even through Postman tests (I get there 404 errors too).
Attempts to Resolve:
Double-checked and ensured the URL used in Make’s HTTP module is correct:
If the webhook that you are creating using HTTP functions on your Wix site is supposed to receive data, then why are you using post in your http-function?
Looking at the code you’ve provided, your frontend page code sends a question to Make, and you’re calling a fetch in the backend for that… are you using the wix-fetch API here?
And when you get the response, you’re returning it back to the frontend?
Then where and how does the HTTP function come into play here?
Even if the HTTP function receives the processed data from Make, how is it supposed to return it back to the frontend?
I don’t see any console log statements anywhere in the code. I’d suggest you do that at every step, and first try creating a simple webhook using http-functions as shown in this video by @thewixwiz:
Once you successfully develop this and test it out, you can then try building it further and integrating it with Make.
There’s only so much I can help without knowing exactly what you’re trying to achieve and if this is the right flow even.
What I’m trying to achieve is to create a sort of “dynamic question and answer” feature in the WIX site.
The user writes his question in one text field
This question is sent to Make via a webhook (this is working perfectly)
Then after processing a reply in Make, I am sending via HTTP module the reply back to the WIX site. The reply should be sown in a different text field. This is what I fail to achieve. I always get an 404 error message in Make’s HTTP module.
So that’s the reason why you’re creating this webhook using http-functions, if I understand correctly. Make will process the reply, and post it to your Wix site’s webhook and then you want to display this in a text field on the frontend, correct?
Well unfortunately you cannot communicate with backend events such as data hooks, or as in your case - webhook triggers directly from the site’s frontend.
You can try bridging this gap with more complicated workarounds involving Wix Realtime, etc but that might not be the most reliable way to achieve this.
If the third party service that you’re using does not send back the requested data in the initial fetch request itself, but instead sends it as a POST request to another webhook (which is kinda funny), then you should consider reframing your logic flow or look into alternative options that will let you achieve your desired functionality.
P.S. If you want to test out your webhooks, you can try out webhook.site or other similar tools available online.
That’s how it technically should be… but without knowing about the specific third party service that you are using, I can’t comment for sure. You should be able to find that out in that particular service’s documentation.
I really struggled getting my first HTTP call ‘into’ Wix to work. In the end, I couldn’t get POST to work, but I did get PUT to work.
So in the Backend http-functions.js file: (notice the ‘put_’ in front!
export async function put_YOUR_HTTP_METHOD_NAME(request) {
let options = {
“headers”: {
“Content-Type”: “application/json”
}
};
// The ‘await’ here is critical! It fails without it!
const theJSONDataPassedIn = await request.body.json();
// Log the JSON data to MyLogCollection which has TWO text fields called ‘In’ and ‘Error’
await wixData.insert(“MyLogCollection”, { In: “Starting put_YOUR_HTTP_METHOD_NAME()”, Error: JSON.stringify(theJSONDataPassedIn ) });
// just resend back the JSON passed in.
options.body = "Exception: " + JSON.stringify(theJSONDataPassedIn );
return ok(options); // this ‘ok’ function is ‘built into’ http-functions.js there are other functions for different error conditions.
} // end of method
Then to call this from an external host you MUST make sure the HTTP call is a ‘PUT’! That’s done differently depending on the calling host.
Not sure about web hooks, not needed in your case (I think)… unless the time to process your HTTP call is very long (like 1/2 hour or more)… The http example below I gave will return any JSON you want back in the HTTP header.