Hi everyone!
I’m excited to announce that we’ve just deployed several improvements to the API connector.
“Allow blank” option to parameters
There is now an “Allow blank” checkbox on API Call parameters. When this option is selected, the key value used to initialize the API Call will not be seen/accessible in the element or workflow property editor that is calling the API. This will allow Plugin or Bubble developers to optionally leave a default value in the API connector for initialization purposes without exposing it elsewhere in the app.
Raw (plain text) body format type
There is a new raw text option for an API call body, in addition to JSON and form-data. Selecting this option allows you to format the body of an API call in the body canvas in whatever format you’d like and specify the format type (ie XML) in a Content-Type Header.
API Call error handling
And, the moment you have all been waiting for (drum roll please…) - error handling for API Call responses!
There is a new checkbox called “Include errors in response and allow workflow actions to continue” that will allow you to handle api call error responses however you’d like. There are two parts to this feature. First, when this checkbox is enabled and your api call returns an error, Bubble will continue the workflow or action (as opposed to the current “fail silently” behavior). Second, we now expose the error object (e.g. "Result of Step 1's API Call's error"
) for use in a dynamic expression. The 4 parameters now available are error status_code, error status_message, error body, and error has_returned_error (yes/no).
As an example of whats now possible, consider the following scenario:
Let’s say I have an API call as the data source for an image element with some dynamic parameter. However, if this API call returns a 404 not found error, I’d like to display a default image instead. We can simply add a conditional to the image element When API - Get Image’s error StatusCode is 404, change data source to the default image.
The documentation will be updated to include more detail on the above three features as well.
We hope you are as excited for these new updates as we are and excited to see what you continue to build as a result!