How to get an API to return a single number value


I’ve been trying for the past couple of days to get a simple API function to work to no avail. I’m basically trying to rebuild what I have on Bubble in Wappler so these are API calls / formats that are already functioning in Bubble.

I’m trying to call an API from my backend (Xano) that is supposed to return a single number. The API is supposed to take in a business_id and then return the number of active projects associated with that business. The basic setup is below where I set the business_id in the input to a global session variable.

I’ve tried different combinations where I put the business_id input variable under GET, PARAM, and SESSION groups both at the global level and also specific to the API but to no avail.

When I Fetch Schema to test the API (see below), it always generates one of two results: 2 or 4, depending on which business_id value I put in the SESSION variable. However, in the snapshot example, it’s supposed to return 1 not 4. I’ve double-checked Xano as well as Bubble and both return a value of 1 so I can’t figure out why Wappler is returning 4.

When I checked the error status and message generated, this is what I saw: "401: Unauthorized [object Object]. I’m confused because this API works on Xano and Bubble.

To summarize, my questions are:

  1. What am I missing and what’s making Wappler not return the correct number for the API call? Why does it keep returning 2 or 4 all the time but not the correct number.
  2. What does the 401 error message mean? I’m using the authentication token and have setup it up correctly. In fact, I call the auth token the same way for my login flow using the same global variable I’m calling to authenticate this API call.

Thanks for your assistance.

Community Page
Last updated: