21656: The ContentVariables Parameter is invalid
MESSAGING, CONTENT
ERROR
Twilio returns this error when your ContentVariables value is invalid for a message request that uses ContentSid. Send ContentVariables as a JSON string of key value pairs that map template variable numbers to substitution values. If a value is omitted, Twilio uses the template's default placeholder value.
ContentVariablesis not a valid JSON string.- A variable placeholder in the template is malformed, such as
{{example}. - A variable placeholder is empty, such as
{{}}. - The
ContentVariablespayload is improperly formatted when you send the message. - One or more variables resolve to
nullor an empty string at send time. - A variable value used in the body contains a newline, a tab, or more than four consecutive spaces.
- Send
ContentVariablesas a JSON string, such as{"1":"coupon_code","2":"docs"}. - Check every template placeholder and use valid double curly brace syntax. Do not use incomplete or empty placeholders.
- Make sure each variable has a non-empty value when you send the message. Do not pass
nullor an empty string. - Remove newlines, tabs, and long runs of spaces from variable values used in the body.
- If you want Twilio to substitute a fallback value, define a default placeholder value in the template before you send the message.