0

I have a requirement to parse the contents of a csv blob which has unicode characters. When I am trying to parse it using

Blob myBlob = EncodingUtil.base64Decode(response.getBody())

I am getting an exception saying -

"common.apex.runtime.impl.ExecutionException: Unrecognized base64 character: \u0003"

What would be the correct way to parse this blob ?

1
  • Is the response even encoded as base64? If it's not, you could simply .toString() the blob.
    – Derek F
    Oct 14 at 11:35
0

The getBody method returns the CSV data as a UTF-8 string. No additional parsing necessary.

String csvString = response.getBody();

If you wanted a blob, use getBodyAsBlob.

Blob csvBlob = response.getBodyAsBlob();

Regardless, if your file has non-UTF-8 characters, you won't be able to read it as UTF-8. You'll need to check the data you're receiving to make sure it's in the proper format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.