I'm trying to decode the body field of the Attachment Object in salesforce doing this:

String bodyContent = documento.Body.toString();
Blob bodyDocumentoBlob = EncodingUtil.base64Decode(bodyContent);
bodyDocumento = bodyDocumentoBlob.toString();

When I try it in the application I get this error:

System.StringException: BLOB is not a valid UTF-8 string

Could anybody help me?

  • 1
    What file type this is? Oct 4, 2016 at 8:42

1 Answer 1


Blob only supports files with UTF-8 format.So Please check whether your file is UTF-8 encoded.You will get this error when there are special characters in the file

You must log in to answer this question.

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