I am trying to get an image located at https://na1.salesforce.com/servlet/servlet.FileDownload?file=00P24000002sSRUEA2 in an apex controller and it complains about authorization..Below is my code
HttpRequest req = new HttpRequest(); req. req.setEndpoint('https://na1.salesforce.com/servlet/servlet.FileDownload?file=00P24000002sSRUEA2');
req.setMethod('GET');
Http binding = new Http();
HttpResponse res = binding.send(req);
Blob image = res.getBodyAsBlob();
System.debug('image' + EncodingUtil.base64Encode(image));
i am new to apex.how do i do this right