How do I extract info from a json string stored in db as a text field?

I’m calling a delete API that gives two separate responses for success and Failure. But unfortunately, Bubble is not able to map the failed response properly so I’m storing that as a raw text in my db.

The response looks like this -
“{"Fault":{"Error":[{"Message":"Delete List Has Balance Error","Detail":"The entity you are trying to delete has an open balance. : This customer can’t be deleted because it has a non-zero balance.","code":"6220","element":""}],"type":"ValidationFault"},"time":"2024-02-27T09:33:44.261-08:00"}”

Is there a way that I can extract the specific parts from this text?

Or can you help me map the response field by Bubble API connecter?

I’m storing this via “Error body” field of API.

It is a strange behavior for Bubble to detect success correctly, but not failure. Could you share your API connector setup?
To better understand this issue, could you share how you’ve configured your API connector? If we’re unable to resolve this directly within Bubble, we might need to consider using external platforms like Zapier as a workaround. As a worst case scenario, it’s possible to extract data using regular expressions (regex), I strongly discourage this approach due to its complexity and susceptibility to errors.

1 Like


I have set up the API connector as None or self-handled. And making a POST call for this specific case. I have several other GET calls that are working correctly. Even other POST calls where I’m not expecting any other failure then 401, are working correctly.

In this case, I’m getting 400 error code when the entry can’t be deleted. I need to catch that reason properly but I can’t.

Here’s how the call looks -

Here’s what happens when I try to map initialize call for a failed response.

I can only map the response automatically when it’s successful otherwise Bubble can’t catch the response when it’s 400 error code.

I don’t want to use Zapier as it’ll add cost.

Start by configuring the API call with parameters that yield a successful response. This initial step checks if you’re using the right endpoint and have the correct authorization. If you get a 400 error, it usually means there was a mistake in your request (Bubble automatically fails the initialization). After this setup, you can build your backend to manage any errors that come up. You don’t need to repeat this setup for every type of error you encounter, you just do it once.

I have already mapped the responses by calling a successful API. That is working fine. The 400 error is defined by QuickBooks (I’m calling their API) when the entity can’t be deleted. They also send the reason for that which I need to catch.

In the case of the 400 error, I’m just getting the response under the “error_reason” header that I shared in the OP. I tried to check all the possible headers but didn’t get the right response in the right format.