Insert From URL with Spaces in Variable

I used “Insert From URL” and the WooCommerce API to edit a product on my website. The response header included a 400 error and a reference to a “control character error.”

Troubleshooting revealed the culprit was spaces in the “short_description” variable string.

An internet search revealed, “To use a FileMaker variable that contains spaces (such as a JSON object) in a cURL request, you must use the @ symbol prefix inside the cURL options string. This tells FileMaker to treat the variable as a data source rather than trying to parse its contents as part of the command line, which automatically resolves issues with spaces and special characters.”

I use custom functions to build my curl options. In this case, I edited the -data curl custom function to add an @ prefix to the $variable name in an attempt to resolve the issue. However, this failed.

My second attempt was to append “@$” to the variable name (without the “$”).

_cURL_data_fn ( “variablename”)

This was successful and eliminated the 400 error. I’m curious about why the first attempt (adding the @ prefix) failed.

The editor changed my “second attempt” — My second attempt was to append “@$” to the variable name (without the “$”).

If I understand correctly, this second attempt looks like it was probably the proper/expected format, e.g.,

--data @$my_variable

or

--data @$$my_variable

If the first attempt to use a $variable with the --data option did not include both the @ symbol and the $ symbol before the variable name, then I would not have expected it to work.

I'll note, however, that I am not entirely confident that I have understood the above post accurately.

Sorry for not being clear. Both attempts should have produced the result above. I’ll have to take a look at the custom function to see how it’s treating the variablename parameter.

1 Like