I’m trying to figure out if there’s a way to remove the entire line of a json request if it’s empty. For some the apis I’m working with, sending empty or null parameters will cause an error, so I’d like to just “erase” that line if the parameter doesn’t have any data.
For instance, if I don’t put the parameter “image” in this request, I want it to show like this:
Right now, it just puts null or an empty string, which causes many of the apis I am using to fail.
As a workaround, I’ve just been creating multiple calls with different options, but that’s obviously unweildy with more than a few optional parameters that need to be removed from the call if they’re blank.
Remove the quotes. “null” is not the same as null. When you are in composer use field value’s is empty :format as text. In the true, put null. In false put “field value”.
If the API doesn’t accept the null at all (rare), set all the line “parameter”:“value”, (be carefull about the comma) and use the same function vut in false, but the whole line including comma if needed (I prefer to put theses fields not at the end and always add a comma). In true, leave empty.
@Jici The api then fails with “expected string and got null”
Can you explain more what you mean by:
If the API doesn’t accept the null at all (rare), set all the line “parameter”:“value”, (be carefull about the comma) and use the same function vut in false, but the whole line including comma if needed (I prefer to put theses fields not at the end and always add a comma)?
Do you have an example of a call using this method? Are you literally just building the call programatically using bubble?