Calling a backend function from a desktop app

I am new at coding web module functions and am trying to call a WIX backend function found in http_functions.jsw from a desktop app source code. I have been reading numerous discussion boards and tutorials on this, but for some reason I continue to get 404 errors. I have tried to reduce the WIX function to something very trivial just to see if I can get the call right. These are the steps I have taken.

  1. Create a WIX export function in http_functions.jsw
    export function multiply() {
    return 6;
    }
    2. Call the function using the url (Note the “dev” since this is an unpublished free site):
    https://jbstmichaels.wixsite.com/wixsite/_functions-dev/multiply
    3. The end result is 404 error

Any help would be greatly appreciated!

You should read Corvid: Exposing a Site API with HTTP Functions and the wix-http-functions API.

You can also see this example:
Expose and Access Site APIs
Use MyApi and MyApiClient to expose and access external APIs.

Yisrael,
Thank you for the response! The example link you provided was great and helped my work out where I went wrong. Really appreciate it!!

Yisrael,

Thankyou for getting back to me. Sorry, if this is not very clear. I am new to web coding.

So what I am trying to do is create a validation process for a digital product license. The product is located on a WIX website and is distributed/sold through sendOwl. I have placed the SendOwl button on the wix website to do this.

Now, to validate the license sent to the buyer by SendOwl, I would like to

  1. incorporate into the code of my digital product a call to the WIX website backend server passing to it the License typed into the digital product by the user.

  2. The backend function in Wix will then call SendOwl to check to see if the License is valid.

  3. It will then return the information received from SendOwl to the program that requested it in the beginning where validation can be checked.

    In other words WIX is acting as the middle man so that I do not have to expose my SendOwl key and secret to the digital product.
    I have managed to accomplish step 1, but am having trouble on step 2. The code that I am using in WIX is:

export function get_Validation(request){
//the “request” parameter will be the license number entered by the client user
//we will construct the url for SendOwl
const owlKey = “{my key}” ;
const owlSecret = “{my secret}” ;
const productID = “{my product ID}” ;

const owlUrl = “https://” + owlKey + “:” + owlSecret + “@www .sendowl .com/api/v1/products/”+ productID + “/licenses/check_valid?{request key}” ;

return fetch(owlUrl, {method: ‘get’ , headers: {Accept: “application/json” }}).then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
}
});

However, when calling this code, I get an internal service error. After some debugging, it seems that the “fetch” call is likely working but it is not returning
it to the digital product. Is this the proper way to call the SendOwl API? Any thoughts on how this might work, even if using a different approach would be greatly
appreciated!

Thanks,
Jim

@jbstmichaels Being “new to web coding”, you will of course face challenges. For your problem, you will need to check with sendOwl how to interface with their API. How do you know that “the fetch call is likely working?” What results do you see? Add a console.log() statement to inspect the returned data from the fetch.

I’m not sure that you have a proper URL to use for the fetch. See Corvid: Accessing Third-Party Services with the Fetch API , and the wix-fetch API for more information and sample code.

A nice simple fetch example to start with is Create a Weather Widget . Also, t ake a look at the Advanced examples , many of them access 3rd party services. A couple of good examples to start with are: Example: Using the Places API from Google Maps services and Example: Send email with the SendGrid REST interface .