You need to sign in to do that
Don't have an account?

System.StringException: Unrecognized base64 character: * in test class
Hi All,
I am getting the error in test class as System.StringException: Unrecognized base64 character: *. I am not getting how to resolve the issue. Could anyone help on this issue.
Thanks in Advance.
I am getting the error in test class as System.StringException: Unrecognized base64 character: *. I am not getting how to resolve the issue. Could anyone help on this issue.
@isTest private class TestUpdateCourseCompletionStatusService { public static testmethod void testupdate() { LMS__c lmsc = new LMS__c (); lmsc.Prod_CryptoKey__c = 'prod crypto'; lmsc.Test_CryptoKey__c = 'test crypto'; lmsc.Prod_IV__c = 'prod iv'; lmsc.Test_IV__c = 'test iv'; insert lmsc; Registration__c coursereg = new Registration__c(); coursereg.Name__c = 'testcourse'; coursereg.ID_Number__c = '1234'; coursereg.LMS_Status__c ='Completed'; insert coursereg; System.RestContext.request = new RestRequest(); RestContext.request.requestURI = '/UpdateCourseCompletionStatus/*'; RestContext.request.addHeader('decodedB64 ', '12345'); UpdateCourseCompletionStatusService.updateCourseRegistration(); } }
Thanks in Advance.
It seems you will have to convert the string ie '12345' to Blob before setting it to the header. Use Blob.valueOf() method to convert the string to blob and then try:
Thanks for your reply. I have tried with your code. I am getting the error as "Method does not exist or incorrect signature: [RestRequest].addHeader(String, Blob) "
RestContext.request.requestURI = '/UpdateCourseCompletionStatus/*';
Then in your controller, you have the following lines:
string enrCourseComDate=endpoint.substring(endpoint.lastIndexOf('/')+1); String enrCourseComDateUTF= EncodingUtil.urlDecode(enrCourseComDate,'UTF-8'); enrCourseComDateUTF= EncodingUtil.urlDecode(enrCourseComDateUTF,'UTF-8'); Blob decodedB64 = EncodingUtil.base64Decode(enrCourseComDateUTF);
Since the urlDecode('*') = '*', you are passing '*' to the base64Decode, which is not a valid base64 character.