• tracker
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Ran the following via an anonymous block. Said:Unrecognized base64 character: � (actually a diamond shaped thing)

The returned value that is anticipated as being a png file is not in a format that can be converted into a b64 file accurately. Does anyone know any methods that might be able to produce a correct b64 string/blob?

If anyone knew how to fix this or had sample code for getting images from google chart api, i would appreciate it.

thank you

 

HttpRequest req = new HttpRequest();

req.setEndpoint('https://chart.googleapis.com/chart?chs=250x100&chd=t:60,40&cht=p3&chl=Hello|World');

req.setMethod('GET');

Http http = new Http();

HTTPResponse res = http.send(req);

blob body;

 //body = blob.valueof(res.getBody());//produces corrupted body

 body = EncodingUtil.base64Decode(res.getBody()); //crashes