+ Start a Discussion

Blob to base64 then to JSON


I have an image stored in Attachment and I want to transfer this image through a REST service. I have tried to use EncodingUtil and convert the blob to Base64 string representation and transfer through my service.

Also I have set of objects in a nested relationship. The Base64 encoded string in the child object, and when I tried to serialize the parent object through JSON.serializePretty(),  it throws the below exception.

System.LimitException: Apex heap size too large: 8693617 External entry point 

How can I overcome of this? Any ideas?