# Need Help with 3rd Party API Integration Using HTTP Functions on Wix

**URL:** <https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760>\
**Category:** Ask the community\
**Tags:** code\
**Created:** [November 17, 2024, 11:48am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760 "2024-11-17T11:48:56Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![itai39144](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/itai39144/32/34043_2.png) [@itai39144](https://forum.wixstudio.com/u/itai39144)\
**Post date:** [November 17, 2024, 11:48am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/1 "2024-11-17T11:48:56Z")

</div>

I’m currently facing a challenge integrating a 3rd party API ([Make.com](http://Make.com)) into my Wix site using HTTP functions and could use some guidance.

**Overview:**

I am trying to setup a workflow where:

1. A custom webhook in Make receives data.
2. Make processes this data and sends a response to my Wix site using an HTTP POST request.
3. 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:

[https://mysite/\_functions/responseHandler](https://mysite/_functions/responseHandler)

- Ensured the backend function is published and accessible publicly.
- Enhanced logging within the function to capture incoming requests and debug the issue.

**Screenshots and Codes:**

1. Code of the responseHandler.web.js file with the HTTP function setup in the Wix backend:

import {ok, badRequest, serverError} from ‘wix-http-functions’;

export async function post(request) {  
let responseHeaders = {  
“Content-Type”: “application/json”  
};

```
try {
    const body = await request.body.json();
    console.log("Received body:", body); // Log the received body for debugging

    if (!body || !body.query) {
        console.error("Query not provided or body is empty");
        return badRequest({
            headers: responseHeaders,
            body: JSON.stringify({
                error: "Query parameter is missing from the request."
            })
        });
    }

    const processedResponse = `Processed query: ${body.query}`;
    
    // Return a successful response with the processed data
    return ok({
        headers: responseHeaders,
        body: JSON.stringify({
            message: "Data processed successfully",
            responseText: processedResponse
        })
    });
} catch (error) {
    console.error("Error in processing request:", error);
    return serverError({
        headers: responseHeaders,
        body: JSON.stringify({
            error: "Error processing request",
            details: error.message
        })
    });
}

```

}

1. Screenshot of the 404 error received when Make attempts to send data:

 ![image](https://us1.discourse-cdn.com/wix/original/3X/a/f/af3eee1daa6d137b90db0fa3ec8ce5136740c6af.png)

I am looking for insights or suggestions on what might be going wrong or any steps I might have missed. Any help would be greatly appreciated!

Thank you in advance for your assistance!

---

<div class="post-metadata">

**Author:** ![giri-zano](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/giri-zano/32/80469_2.png) [@giri-zano](https://forum.wixstudio.com/u/giri-zano)\
**Post date:** [November 17, 2024, 9:46pm UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/2 "2024-11-17T21:46:36Z")

</div>

Let me get this straight: you are posting to this URL: [https://mysite/\_functions/responseHandler](https://mysite/_functions/responseHandler)?

---

<div class="post-metadata">

**Author:** ![itai39144](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/itai39144/32/34043_2.png) [@itai39144](https://forum.wixstudio.com/u/itai39144)\
**Post date:** [November 17, 2024, 10:12pm UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/3 "2024-11-17T22:12:44Z")

</div>

Yes, except instead of mysite I put of course the real address of my site

---

<div class="post-metadata">

**Author:** ![Pratham](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pratham/32/119586_2.png) [@Pratham](https://forum.wixstudio.com/u/Pratham)\
**Post date:** [November 18, 2024, 5:07am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/4 "2024-11-18T05:07:29Z")

</div>

Hey Itai

> [@itai39144](#):
>
> I’ve set up an HTTP function (`responseHandler.web.js`) in the backend section of my Wix site to handle incoming POST requests.

HTTP functions can only be written inside a specific file in the backend called `http-functions.js`

I’d recommend you go through the Wix Velo developer documentation first to learn more about it.

> **[Write an HTTP Function | Velo](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/integrations/exposing-services/write-an-http-function)**
>
> HTTP functions define custom site APIs, which allow you to expose your site's functionality externally. This means that you, or other people, can access your site's functionality by calling your custom site APIs.

Here are some additional tutorials:

> [@Help for adding items to collection/database from external app?](https://forum.wixstudio.com/t/help-for-adding-items-to-collection-database-from-external-app/63644/2):
>
> Hey Alper, This super informative tutorial by @thewixwiz will show you how to set up HTTP functions on your website: [[How to use Wix HTTP Functions] ](https://www.youtube.com/watch?v=jH48Gd102a4)[[How to Use HTTP Functions to Expose Your Site's API | Velo by Wix] ](https://www.youtube.com/watch?v=4yCBplV3MPQ)

---

<div class="post-metadata">

**Author:** ![itai39144](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/itai39144/32/34043_2.png) [@itai39144](https://forum.wixstudio.com/u/itai39144)\
**Post date:** [November 18, 2024, 9:49am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/5 "2024-11-18T09:49:55Z")

</div>

I tried what you said, and it doesn’t help either. It simply doesn’t work.

Current codes are:

**Backend file named “makeApi.jsw”:**

```javascript

export function sendDataToMake(data) {
    const url = 'MY WEBHOOK URL';
    return fetch(url, {
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(processedData => {
        return processedData; 
    })
    .catch(err => {
        console.error('Failed to send data:', err);
        throw new Error('Failed to send data: ' + err.message);
    });
}

```

**Backend http-functions.js file:**

```javascript
import {ok, serverError} from 'wix-http-functions';

export function post_responseHandler(request) {
    return request.body.json()
        .then(body => {

            console.log("Received data:", body);

            const responseData = {
                message: "Data processed successfully",
                yourData: body  
            };

            return ok({
                headers: {"Content-Type": "application/json"},
                body: JSON.stringify(responseData)
            });
        })
        .catch(error => {
            console.error("Failed to process request:", error);
            return serverError({
                headers: {"Content-Type": "application/json"},
                body: JSON.stringify({error: "Server error occurred", details: error.message})
            });
        });
}

```

**And the front end code on the page itself:**

```javascript

import { sendDataToMake } from 'backend/makeApi';

$w.onReady(function () {
    $w("#searchButton").onClick(function () {
        const question = $w("#searchInput").value;
        if (question && question.trim().length > 0) {
            sendDataToMake({ query: question.trim() })
            .then(data => {
                $w('#responseTextField').text = data.responseText; 
            })
            .catch(err => {
                console.error('Error:', err);
                $w('#responseTextField').text = "Error retrieving answer";
            });
        } else {
            console.log('Invalid input. Please enter a question.');
            $w('#responseTextField').text = "Please enter a question.";
        }
    });
});

```

---

<div class="post-metadata">

**Author:** ![Pratham](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pratham/32/119586_2.png) [@Pratham](https://forum.wixstudio.com/u/Pratham)\
**Post date:** [November 18, 2024, 10:31am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/6 "2024-11-18T10:31:42Z")

</div>

What are you trying to achieve here?

> [@itai39144](#):
>
> 1. My Wix site’s backend function is supposed to receive this POST request and process the data.

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?

> [@itai39144](#):
>
> ```javascript
> export function post_responseHandler(request)
> 
> ```

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?

> [@itai39144](#):
>
> 1. A custom webhook in Make receives data.
> 2. Make processes this data and sends a response to my Wix site using an HTTP POST request.
> 3. My Wix site’s backend function is supposed to receive this POST request and process the data.

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:

[![](https://us1.discourse-cdn.com/wix/original/3X/3/a/3a0c67ea01e20ab38f77d3f65840a6e37fdc8c5a.jpeg "How to create a Webhook on Wix") ](https://www.youtube.com/watch?v=zocHQ2STxBs)

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.

---

<div class="post-metadata">

**Author:** ![itai39144](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/itai39144/32/34043_2.png) [@itai39144](https://forum.wixstudio.com/u/itai39144)\
**Post date:** [November 18, 2024, 10:51am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/7 "2024-11-18T10:51:44Z")

</div>

What I’m trying to achieve is to create a sort of “dynamic question and answer” feature in the WIX site.

1. The user writes his question in one text field
2. This question is sent to Make via a webhook (this is working perfectly)
3. 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.

---

<div class="post-metadata">

**Author:** ![Pratham](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pratham/32/119586_2.png) [@Pratham](https://forum.wixstudio.com/u/Pratham)\
**Post date:** [November 18, 2024, 10:59am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/8 "2024-11-18T10:59:38Z")

</div>

> [@itai39144](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![itai39144](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/itai39144/32/34043_2.png) [@itai39144](https://forum.wixstudio.com/u/itai39144)\
**Post date:** [November 18, 2024, 1:13pm UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/9 "2024-11-18T13:13:13Z")

</div>

Exactly. That’s what I am trying to do.

---

<div class="post-metadata">

**Author:** ![Pratham](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pratham/32/119586_2.png) [@Pratham](https://forum.wixstudio.com/u/Pratham)\
**Post date:** [November 18, 2024, 1:55pm UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/10 "2024-11-18T13:55:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![itai39144](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/itai39144/32/34043_2.png) [@itai39144](https://forum.wixstudio.com/u/itai39144)\
**Post date:** [November 18, 2024, 7:16pm UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/11 "2024-11-18T19:16:00Z")

</div>

Is it possible to fetch the reply after being processed on the third-party with the same webhook that sends the data from the WIX site?

---

<div class="post-metadata">

**Author:** ![Pratham](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/pratham/32/119586_2.png) [@Pratham](https://forum.wixstudio.com/u/Pratham)\
**Post date:** [November 18, 2024, 7:58pm UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/12 "2024-11-18T19:58:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Phil\_Kochan](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Phil\_Kochan](https://forum.wixstudio.com/u/Phil_Kochan)\
**Post date:** [November 25, 2024, 1:40am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/13 "2024-11-25T01:40:49Z")

</div>

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.

Then the HTTP call is:

[https://mysitexxx/\_functions/YOUR\_HTTP\_METHOD\_NAME](https://mysitexxx/_functions/YOUR_HTTP_METHOD_NAME)

NOTE: There is NO ‘put\_’ at the front of the call! This is not documented well in Wix (that I could find). Again, post doesn’t work!

I don’t check this forum really at all… if you email questions to philkochan  
at  
msn  
dot  
com

I might be able to help. Again, I pulled my hair out for a half a day on this! ☹

---

<div class="post-metadata">

**Author:** ![Phil\_Kochan](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Phil\_Kochan](https://forum.wixstudio.com/u/Phil_Kochan)\
**Post date:** [November 25, 2024, 2:00am UTC](https://forum.wixstudio.com/t/need-help-with-3rd-party-api-integration-using-http-functions-on-wix/64760/14 "2024-11-25T02:00:14Z")

</div>

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.
