0

I'm linking a ContentNote to a Lead object, but the notes that i've been making are showing symbols like "��br��z{^�Ʃx{f" instead of what is provided in the post call to the api.

Any ideas on why this is happening?

5
  • 3
    Looks like a character encoding issue. Did you perhaps mistakenly send your request with the ISO 8859-1 or Windows-1252 character sets instead of UTF-8?
    – Derek F
    Commented Jan 3, 2018 at 20:12
  • i checked the headers and they're alright content-type →application/json;charset=UTF-8
    – Oscar Or
    Commented Jan 3, 2018 at 20:19
  • 1
    It could still be an encoding issue (though less likely). Additional details will be helpful here. What API are you calling, and from where (anonymous apex, regular apex, PHP/C#/Javascript/etc...)? How are you building your JSON payload?
    – Derek F
    Commented Jan 3, 2018 at 21:01
  • 1
    the rest api. I've tried with both Postman and Python3. Json goes like this: { "Title":"titulo", "Content":"contenido" }
    – Oscar Or
    Commented Jan 3, 2018 at 22:00
  • Weird thing is that the title of the note is being displayed correcly
    – Oscar Or
    Commented Jan 3, 2018 at 22:02

1 Answer 1

2

Looking at the SOAP API documentation for ContentNote (yeah, I know you're using the REST API), we see that the Content field stores (and thus expects) a base64-encoded string.

Trying to put a normal UTF-8 string into this field will result in Salesforce displaying a sequence of strange (and possibly unprintable) characters.

Base64 encoding your content before you post it to the API should resolve the issue.

2
  • You've saved my life man, thank's a lot!
    – Oscar Or
    Commented Jan 4, 2018 at 15:57
  • @OscarOr It was your comments that included the JSON and saying that the title displayed correctly that pointed me in the right direction. For the future, if you're trying to work with a standard Salesforce object that doesn't appear in App Setup -> Customize (or it does and you can't see the fields for the object), the SOAP API documentation is extraordinarily helpful (even if you're not using the SOAP API). The SOAP API documentation does a fairly good job at telling you the api names for fields, their data types, and whether or not you can read/set/update them.
    – Derek F
    Commented Jan 4, 2018 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .