Extract a JSON Error from an API

I am trying to correct a workflow error where a customer is not created if the phone number is already taken. This is the JSON response I get back from the API. I currently have the API response for successfully creating the customer writing that data back to Bubble. But I want to have a conditional in the workflow that if the “message”:“Phone has already been taken” appears, create the record without the phone.

This is the JSON error data
{
“data”: {
“customerCreate”: {
“customer”: null,
“userErrors”: [
{
“field”: [
“phone”
],
“message”: “Phone has already been taken”
}
]
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 10,
“actualQueryCost”: 10,
“throttleStatus”: {
“maximumAvailable”: 2000,
“currentlyAvailable”: 1990,
“restoreRate”: 100
}
}
}
}

and this is my attempt to see if “message”: “Phone has already been taken” is present in the raw body text. My first conditional is if the previous step does not have an id, then repeat the step if the message is present.

Actually, your “contains” part is not correct and should just care about “Phone has already been taken” part (without quotes)

However, I suggest you to, instead, modify the response payload parsed by Bubble to include possible error like this and instead, use body data’s customerCreate’s userErrors:first item’s message is Phone has aleady been taken

You ever feel like Bubble is like those 1970’s jets that had 5000 buttons, knobs, and switches on it. And if you forget JUST ONE - BOOM.

Yeah, I have 12 API calls to Shopify and 11 of them were checked on. Now you make me feel like BOOM. I missed a switch!

1 Like