-
Notifications
You must be signed in to change notification settings - Fork 27
Description
* and likely other characters that require URL encoding.
Particle.variable() and Particle.function() will accept a key string containing spaces, and these key strings are successfully conveyed to clients via the getDevice() API call. However, trying to use getVariable() or callFunction() fail because the key string forms part of the URL for the underlying GET / POST request.
URL encoding the key strings does not help. The Particle Cloud does not appear to decode them into the correct key strings internally.
I think it makes sense to add validation to Particle.variable() and Particle.function() to avoid this issue. We could either indicate failure by the return value, which is in line with the documentation for Particle.function(), or else just strip out the offending characters and replace them with something conspicuous. This might be more user friendly as it's somewhat involved on a board like the Oak to check the return value and communicate it via the LED or serial.
Particle.publishEvent() may also need similar validation, although I haven't yet found characters that cause problems.
To properly fix this, we need to know the list of characters allowed for variables, functions and events in the Particle Cloud. @digistump do you know what these chars are? If not, could you ask the Particle devs?