REST API Unicode characters not working
I've been able to reproduce this in a test environment using Workbench. It appears that Salesforce by default interprets text in the body of a request with Content-Type: application/x-www-form-urlencoded
as either ISO Latin-1 or UTF-16, which is why that specific piece of text yields an eth character (Unicode/Latin-1 F0
).
If you can get Twilio to send the header Content-Type: application/x-www-form-urlencoded; charset=utf-8
, I've confirmed that this fixes the issue.
Unfortunately, it looks like Apex grabs the request body and deserializes it to params
before we actually ask for params
, and the original binary request content is no longer available by the time it gets to us. Further, setting the Content-Type header on the RestRequest
object once it gets to Salesforce has no effect.