0

I am getting the error mentioned in title of this question when I am calling one of my class method from a test class which is there to send the email with an attachment. Inside that method which is getting called, the second line mentioned below is causing issue:

        Type idArrType = Type.forName('List<string>');
        List<string> wrapperList = (List<string>) JSON.deserialize(attachId, idArrType);

The attachId is getting received properly by the method as checked by using syste.debug but what is the role of this idArrType here? As this class was created by someone else, I also have no idea and specially with this JSON issue. Any guidance will be helpful.

  • Could you please share what exactly is passed in attachId? It seems like a malformed JSON error – nchursin Apr 10 at 13:42
  • Also, you can replace Type.forName('...') with List<string>.class – nchursin Apr 10 at 13:43
  • Id of the attachment record is passed to it..as a string. – Aditya Apr 10 at 13:43
  • ok will give it a try. But I think the class is working fine as it was builde 1 or 2 years ago. Its just that when I am calling it from a test method now, it is throwing error.May be some modification was done to class as well but I am not aware of it. – Aditya Apr 10 at 13:45
  • 1
    attachId must be valid JSON list - e.g. ["someId"] – cropredy Apr 11 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.