Forum Academy Marketplace Showcase Pricing Features

How to catch a 400 error from API connector?

I’m using a (kind of) API for Duolingo, which, when an invalid username parameter is supplied, returns a 400 (Bad Request) status code and a load of HTML, which then throws an uncaught error in the API connector, in the console:

POST 400 (Bad Request)

x1:98 Uncaught {statusCode: 400, message: "Error parsing data from Apiconnector2: <!DOCTYPE h…Listener("load",t.captureLoad.bind(t)),r.addEvent", _original_request: {…}, stack: "", args: {…}, …}

I would have thought this would kick off the “An unhandled error occurs” event in workflows, but it doesn’t seem to. I’ve also tried checking for when the value of the API’s response is empty with no luck. Any ideas about how to catch when this occurs so I can display an appropriate error message to the user?

Here’s a demo of the issue:

So, I found a solution to this in case anyone else is encountering the same thing. Add the same API call as a second API call, this time setting the Data Type to “Text”. This will return an object resulting in the string “[object Object]” whatever the result- whether it’s a properly formatted result or the 400 error page. So now you can check for a condition where API 2’s result is [object Object] and API 1’s result is empty, meaning the 400 error happened.


Thanks for this solution! Hopefully it will work in my situation.

Two questions.

  1. is this still the most effective solution that you’re aware of?
  2. do you have an example of the implementation that i could look at?

@team is there a better way in 2020?


That should be addressed by Bubble

1 Like

I actually tried this and was able to fetch 200, 302, 400 messages

I’ve checked with Bubble support, and they’ve told me that is the way indeed (nested call like @dambusmedia)

I am having the same problem - I need to catch http 400 errors generated by an external API call.

But my API calls are set to “actions” not “data” because I want to use them as actions in workflows.

Unless I’m not understanding correctly, this means I cannot implement the nested API solution because only “data” api calls can be used in the “only when” section of a workflow.

I really hope I’m misunderstanding and this is in fact possible. Because I’ve been searching and searching and this is the only solution I’ve found for catching 400 errors in API calls.

Can anyone confirm this? Do you know of another workaround?

You can wrap the API call in Integromat. Pull the return from the API and pass it back to Bubble, with a “real” return code of 200 to fool Bubble into thinking everything was fine.

Video at #NoCodeBoss


Thanks! Got this setup today :slight_smile:

1 Like


Implementing the nested calls means the API will be actually called twice?

I’m using it for a checkout integration with the payment GW and if that is the case, than the user would be charged twice and that won’t work for me.


It seems like bubble team has fixed it.
There is now a checkbox “Include errors in response and allow workflow actions to continue” in the API call settings. You can check it, and handle the steps in the backend workflow with "only when → ‘returned an error’ is no/yes " rules. Works like charm, thanks Bubble team!

1 Like