I know I already ask on how to convert the Dashboard into an image about a week ago. But that code isn't working for me. All i getting from that code is a blank image rather then an image of the Dashboard. I'm not sure if it's is the URL problem or my codes problem.
Can Anyone Help me Fix it?
What I'm doing is:
- Convert the Salesforce Dashboard into an image file
- Store the Image file into the Document Folder
Code
I have already tried using jpg and the result is still the same
String base64Data = '';
HttpRequest req = new HttpRequest();
req.setEndpoint('https://ap4.salesforce.com/01Z/o');
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);
Blob image = res.getBodyAsBlob();
base64Data = EncodingUtil.base64Encode(image);
System.debug('image= ' + image);
Document doc = new Document();
doc.Name = 'SF Dashboard Image.jpeg';
doc.body = EncodingUtil.base64Decode(base64Data);
doc.folderId = '00l6FA00001pqSe'; //your folder id
insert doc;
System.debug('Insert= ' + doc);
I have also tried
req.setEndpoint(EncodingUtil.urlEncode('https://ap4.salesforce.com/01Z/o', 'UTF-8'));
But i get this error message
System.CalloutException: no protocol: https%3A%2F%2Fap4.salesforce.com%2F01Z%2Fo
Salesforce Dashboard URL
I copied the URL that I highlighted in blue


