Include errors in response and allow workflow actions to continue

Is this working correctly on 200s?

The API I am calling correctly returns a 200 in the status code but in the back end the only field that is available in the workflow is returned_an_error being “no”. Despite 200 coming back from the API.

The assumption here is that the ONLY non-error status code is 200?

Not really sure that is true.

Exactly. A 20x response is technically not an error. But some API will return 200 but have a payload for error. What you need to do is to merge the good payload with the error payload and enter it manually. Use conditionnal to detect error message. In this case, using continue workflow doesn’t matter because the API doesn’t return an error code le 40X or 50x.

The issue is that you have no way to tell what the API returned as a response.

Despite the fact the the API DID return a reponse code, Bubble simply refuses to pass it on to you if “returned_an_error” is no.

Really don’t think this is how it should be working.

I don’t agree. But I don’t understand what you mean by

When you initilize the API, you have the response. But in this case, you need to enter the response manually by merging this response and the error payload.
Let’s say you have a good response:

{"itemid":"123456","success":"true"}

The error payload is

{"error":"error message","success":"false"}

You will manually enter:

{"itemid":"123456","error":"error message","success":"false"}

Also, you can use “raw body” that should be available, but not parsed.

The alternative here is to tick the “include errors in response box”?

So here we have an “OK” response on Initialise (it happens to be an image) but we also get the OK and the 200 back in the raw response.

If there is an error then the workflow will continue and you can use the status_code in the flow.

Screenshot 2023-04-24 160829

However, despite the fact that the raw response has status_code 200 when you get this into the workflow Bubble ignores the status code and just gives you returned)an_error = no.

Screenshot 2023-04-24 160945

I don’t beleive this is correct, as there are multiple 2xx responses that are “not an error” and using the built-in Bubble function for this purpose means you can’t tell what the actual return code is - you just know it isn’t an error.

1 Like