Hello,
I am trying to send an empty value to Postmark, but the bubble is sending null.
How can I send an empty field instead of null? I have been trying to solve this for the day now with no success.
Hello,
I am trying to send an empty value to Postmark, but the bubble is sending null.
How can I send an empty field instead of null? I have been trying to solve this for the day now with no success.
Uncheck the āallow blankā in the API connector. This sends ānullā if it is empty. Alternatively, you can always do a condition that says āif the value is empty send a space insteadā so itās not empty.
Normally when creating the API call, if something can be empty, instead of putting the value like this:
"companyDivision": "<companyDivision>"
I would do this instead:
<companyDivision>
then in the value I would do this "companyDivision": "<companyDivision>"
so that in the workflow, the whole part can be dynamic, if it is empty, donāt put anything in it.
Thank you very much for your reply. I found a solution 5 minutes ago, actually, so I will write it here so everyone can see if they have a similar issue.
The main issue is that I was trying to send my values like this:
"companyDivision": "<companyDivision>"
, which should have been done differently. Instead of writing the previous code, write this one:
"companyDivision": <companyDivision>
And do not use āā. The reason to do so is that bubble is writing null for the empty string, which postmarks read as empty, but when you have āā, it literally sends the text ānullā.
The next thing to do is, when you are assigning value to in any workflow, make sure that you write dynamic value:formatted as json safe. If you assign :formated as json safe, the bubble will add āā automatically if there is any value.
I hope that Iāve explained it so it can be understood. If anyone canāt, feel free to message me.
I am confused and I couldnāt find answers throughout the forum. Will appreciate if anyone could shed some light.
1.) Can you achieve the same without explicitly constructing the JSON body?
(First, I use a NoCode platform to reduce the need of hardcoding. Second, everytime I update the JSON body I have to reset all the params settings)
2.) For dynamic data, eg, from a Inputās value, it just wouldnāt send an empty string nor null. If I tick optional, the request skip the field. If I donāt tick optional, either āallow blankā or not refuse to accept the empty value.
Context: I am writing an API call for a PUT request. I want to be able to set something to empty.
Thanks you!
Unfortunately, it is how it isā¦ I had the same problem that I had to reset all the parameters. But yes, you need to use JSON body if you want full customization.
If it is empty, it will not send anything. What are you trying to achieve?
Thanks for the reply!
I am just building a simple form to send a PUT request to my Django backend to update the model.
So very intuitively if my user empties out a an input field, letās say, āremarksā, I would be able to send a json body of
{ āremarksā:āā}
So my backend updates the remarks to an empty string.
However, in the bubble app, if the user empties the input field, bubble just gives an error saying Params remark cannot be empty. (whether allow blank is checked or not)
I know I can get it working by building the JSON body myself, but it will bring inconsistency among API params in workflows.
For example, for these kind of custom constructed JSON body, you need to enclose with āā; for calls using bubbles default form, you shouldnāt, otherwise it will wrongfully send extra āā.
(Updates: as you said, ājson-safeā is better than enclosing with āā. But it gives the same problem of extra āā when paired with default calls)
The inconsistency will make maintenance and collaboration very hard. Meanwhile I also donāt want to refactor all my other 30+ api calls to work this way.
Iām just surprised there isnāt a way just to send an empty string from an input field without workarounds.
This is cool, but does it work if you are doing body type: raw?
ācustomerā: {
āfirst_nameā: customer_first_name,
ālast_nameā: customer_last_name,
āemailā: customer_email_1,
email_subscribe
ātagsā: customer_tag
If I initialize with nothing in there and allow blank = true I get bad requestā¦
Hmm @neilmagnuson11
In the workflow are you doing āformatted as JSON Safeā?
Oh, and if you initialize you have to have something there temporarily. Once initialized you can delete the values.
Thanks for the tip on initialize temporarily.
Here is what I have:
No means its null, not showing on the screen at all for the user to click.
The yes works, but when its no i get a weird error:
Any ideas?
Instead of removing the line, you can keep the key and just set the value
So in json it will be "buyer_accepts_marketing":_*_email_subscribe_*_,
In the dynamic field, you keep :format as text
On yes: true
on no: false OR null
However, it actually hard to tell you whereās the error. You have a lot of field, be sure to encode them correctly using :format as json-safe if needed.
Also, donāt forget to set the content-type header to application/json
Sometimes, to make it easier to figure this sort of thing out, I suggest using Arbitrary Text for everything. Then you can also save the arbitrary text into your database. That way, you can take it and put it in a JSON validator to see what the issue is. It might be a comma that is there that shouldnāt be if the value is empty. You might be able to see the data in the Bubble Logs possibly. Can you see all the data somewhere and see what it is actually being sent?
Had to comment to this because it helped me for my Supabase backend workflow, and for anyone searching on the solution. Thank you so much @J805
@faisalkarimstubapp So glad that helped.
And this one from @zoombackdrops is a really great solution as well. Thank you for pointing this out. It helped with my Supabase backend.
Does anyone have any suggestions on how to return ānullā when using the Return data from API function?
Can you share a print screen?