Is it possible to make query string parameters optional in the API Connector (or API tab of the plugin editor)?
There’s no checkbox to explicitly mark them as optional like there is for headers and body parameters; and if no value is provided, Bubble just sends a valueless parameter, which in the case of this API has specific meaning that is different from not including the parameter at all.
I’ve been tinkering, but I can’t find a way around this. Has anyone had success doing this?
I have something for JSON actually, but not for url parameters.
Did you use setting in Body or only in URL? (is it a GET call or POST?) or in Form DATA with add parameters button?
Query string params 1 and 2 get sent even if there’s no value specified for them in the editor. I was just hoping I was overlooking some way to prevent them from being sent if they have no value - i.e. make them optional. It appears it’s not possible with the API Connector.
Ok. Because you are in a GET request, you don’t have access to body like you have in POST.
I think the best thing would be to create a plugin if you have a lot of possible missing field. If there’s two or three, you could consider using conditionnal to provide correct parameters
instead of putting them in the API connector, you put everything after ? into one [parameters] and in this parameters, you wil lset param1=value1¶m2=value2 (and in editor, you replace the value with dynamic token.) If you have a lot, I think a plugin will be easier to use and create
Of course, that was in the context of the body, and I never even thought to consider that it might apply to the URL itself!
Anyway, thanks much for bringing a fresh perspective to the issue. And thanks, @Jici, for your suggestions as well, but I really wanted to get this to work in the API Connector and/or plugin editor API tab.
This was the same suggestion I had. The only difference is each part separate while I was doing everything after in one
My process was the same setting, just the difference in the action process when you call the API
I only think that with the approach from Richard, is that you probably use conditionnal to set the fields right?
I guess I misunderstood then. My apologies! Either way, I’m happy to have learned something new. Thanks again for taking the time!
EDIT
Yeah, I think it was your references to a plugin that caused me to miss the relevant part; so thanks much. The API Connector is actually much more flexible than I realized!
In fact, I’ll be passing a list in the query string, so I’ll likely use just a single editor field - i.e. “param” - in conjunction with the new[ish] list :formatted as text feature.