APIs return values

I created an API call to supabase called update user info which is suppose to update specific columns of a supabase user row but when I initialize the API call, it returnes an empty array and the data doesn’t get updated in supabase. but I made that same API call in postman and it worked perfectly. what exactly am I doing wrong?

Also, I’m not using the bubble supabase plugin. I’m using the supabase website. I currently can’t afford that. I also changed the authorization header to Bearer {{current user’s access_token}}

If in that JSON body you’re passing it exactly like that, it won’t work, because you’re using {{VALUE}}, and that makes the JSON invalid. It works in Postman because it treats values inside double braces as variables you can edit, but Bubble doesn’t work like that. You need to use <value> instead, so it becomes dynamic and you can fill in the fields that appear, like in the image below:

Also, when you’re making the call in your workflow, be careful to keep the JSON valid too.

When making the call in your workflow, what I do is remove the quotes from the JSON body in the API Connector, like in the image below:

Then, in the workflow, I format the values as JSON:

Remember that if any of these values are empty and you send them just between quotes, Supabase will create that item, but the column that was empty will literally contain the text: null. To avoid this, you must ensure that if it’s empty, you send null instead of “”. So you should also format that in your workflow, for example:

first_name is not empty: formatted as text:
true: first_name:formatted as JSON-safe
false: null

Always remember to use this header as well:
Prefer:return=representation

1 Like

it still isn’t working. I even placed actual values in the value box, but it still isn’t updating in supabase. I’ve also used chatgpt and tried all that it has suggested but it still didn’t work

When you click initialize, what happens? And when you look in Supabase, has the item been edited?

when i click initialize, it returns nothing (an empty array) and no, the supabase item has not been edited

I found what you’re doing wrong LOL, I hadn’t even noticed that, the location_id shouldn’t be in the body but in the URL :man_facepalming:t2:

after /v1/users

Put it like this:

/v1/users?location_id=eq.[location_id]

Then, in the dynamic parameter, put the location_id ID and remove it from the json body.

Follow the steps below, and you will get exactly what you want:

Why this solution works:
I am not very experienced with the Supabase API, but I think this will help. When you initialize an API call in Bubble, some APIs, like Supabase updates, don’t actually change anything if the sample data doesn’t match an existing row. Bubble just needs a sample response to understand the data structure. By adding a sample response manually, the call can be initialized correctly. After that, real updates will work when the user sends the actual data.

Steps:

  1. Copy a sample API response from Supabase documentation.
  2. Paste it manually into the Bubble API Connector to initialize the call.
  3. Now send the real data from the front-end you want to update.
  4. The API will now update the data correctly using the information from the user.

It still isn’t working. could you try it and if it works then you let me know the exact setup

this also didn’t work

Well, then the problem isn’t with Bubble there. Are your RLSs active? In Authorization, what access token are you passing there?

Now there are two possibilities, in my opinion.

Your RLSs are active, but without a rule or with an incorrect rule, so if you don’t pass service_role in Authorization, it won’t work.

Or the location_id item there doesn’t exist.

yes, RLS are active and i added an update policy and a few other policies. In Authorization, i’m passing the the current users access token which is stored in a different data type called usertokens. the location_id column exists

You can provide an open bubble.io editor link so we can help you directly into your app.

Disable RLSs, replace the usertoken authorization with service_role, and test again. If it works, your problem is with RLSs.

it still didn’t work

are both of you guys on a platform which I can use to send you the editor link

Let’s work together on Slack. Use this link to start a direct message with me: rjayaddi is inviting you to message them with Slack | Slack

I’ve sent it, my username is Benaiah Aheto

Hey @blasterf98

Perfect, got your message. Will check it by today. Let me know your availability so you can give me permissions.

Thanks

I’m available the entire day so when ever you check it out, let me know. I just texted you on slack