+ Start a Discussion
prasanth sfdcprasanth sfdc 

Line: 5, Column: 1 System.StringException: Unrecognized base64 character: %

I am trying to get PDF attachment from amazon s3 into salesforce, While converting into Base64 i am getting this error. 

Error is thorwing in the last line dubug statment as below. 
Line: 5, Column: 1 System.StringException: Unrecognized base64 character: %

string url = AWSUtility.viewS3Object('a1h01000000Hk1r');
system.debug('The url is:' + url);

Http http = new Http();
HttpRequest request = new HttpRequest();
HttpResponse response = http.send(request);
system.debug('The response is :' +EncodingUtil.base64Decode(response.getBody()));

and i have tried like this also for the last debug like but, not working
Line: 15, Column: 1
System.JSONException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]

Please help me to solve this. 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Prasanth,

Generally, this is because of sending the wrong JSON format on URL using the client. Just check your JSON data which you are trying to send over URL. If you get this kind of exception. Then You just make sure that data is in the correct JSON format!

I found the below implementation that had a similar issue and there is the best answer you can try checking.

>> https://developer.salesforce.com/forums/?id=9060G000000XekyQAC

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.