Boolean value in API Connector

Hey bubblers! I trying to connect an API with API Connector, i used POST Method and in the json body i need to send riquired values and one of the values is boolean but i don’t know how i can send, i try to send “True/False”, “Yes/No” and “0/1” but is not work. In the API Doc says to send “false/true” when i click in Initialize Call, return Error 422. Anyone can help-me? Thanks!

1 Like

I think, but not sure, that you will need to use JSON Body instead.
When you use parameters, Bubble create a JSON payload from them. But… Bubble doesn’t have specification for the type of field the parameters is (integer, boolean, string…) So they are all encoded in string!
But in JSON, a boolean type exist And the difference is important for a lot of API Services.
So actually I suspect that Bubble encode your parameters like that: “simple”:“true” while it should be encoded like that: “simple”:true
So if you create a JSON body and delete all parameters, you will use:

	"name": "<name>",
	"simple": <simple>,
	"brand_id": "<brand_id>",
	"description": "<description",
	"active": <active>

I have encoded the brand ID as a string but it may be an integer. In this case remove double quotes around this value.
Don’t forget to set header Content-type:application/json

1 Like

Thanks for your anwser but didn’t work yet, i keep try to make it’s work… I sended one mensagem to Bubble Support, maybe he can hel-me or engineer team help me too, in the forum doesn’t exist asks for this question, that is funny because some API need to boolean values in the json body, but, thanks for spend your time read and write to me, i apreciate this.

Can you share API doc link? And the full screenshot of the attempt with the json payload?

This topic was automatically closed after 70 days. New replies are no longer allowed.