so I’m trying to send a dynamic email using the plugin “Send email with Sendgrid” and when I set up dynamic content from Bubble (input containing a URL) that contains special characters such as : / ? & or = into one of the JSON objects I get a JSON parse error Unexpected token.
Anyone knows how to prevent this? Is there a way to escape these characters so my string is a valid JSON?
URL encode your text first. All objects of text type have the :formatted as… operator. One of the options there is “URL encoded.” See: https://bubble.io/reference#Data.Messages.text.format_text
Ok so I wasn’t formatting the entire string but just the URL part and it didn’t work. Now I’m formatting as URL the entire string it works, the content is passed and the email is sent BUT the email is impossible to read since the content is full of numbers and %…
How can I make it readable for my users?
I was just suggesting on the URL part actually. Sorry. There must be someone round here that goofs around with SendGrid more than I…
well yeah, that would make more sense but it didn’t seem to work. I’ll keep playing with this
Backspaces seem to be the problem. That’s why when I format everything it goes through and when I format only the URL it doesn’t.
Use these escape characters with the :find&replace. You can do find&replace over and over on your text to get them all taken care of. Make sure to find \ first and replace it with a double backslash since the subsequent escape characters contain a backslash.
a new feature was added that makes this super easy: You can now change text strings, dates, etc. with the …:formatted as JSON-Safe function. Please note that it also adds " … " quotation marks arond your escaped text string, so you don’t need to add these again if you create a JSON object.