• Andrea Barquin
  • NEWBIE
  • 10 Points
  • Member since 2017
  • Kaseya

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello,

We recenlty refreshed our sanbox and we started getting  "System.CalloutException: Unexpected end of file from server" error when making an API call to the external service from our sandbox environment. It used to work fine before and the same call is still working in our production environment. 

There are no blocking rules in the Firewall. Is there a way to diagnose? Is possible to get something similar to a traceroute from the sanbox to our server where the API resides?
I have an apex extension for a visualforce page that sends emails using the SignleEmailMessaging method. It sends email using an email template with merge fields from a custom object called ParticipantEmail. However, I am getting an error on the WhatId method call.

here is that part of the code:
       //the class WrapTemp has two attributes, one of type ParticipantEmail__c named tempRec and the second one is a string named type_member
        for (WrapTemp wCM : pEmails){
            Messaging.SingleEmailMessage mess = new Messaging.SingleEmailMessage();
            List<String> bccAddys = new List<String>();
            bccAddys.add(UserInfo.getUserId());
            mess.setBccAddresses(bccAddys);
            system.debug('wCM.tempRec.ContactId = ' + wCM.tempRec.ContactId__c);
            system.debug('wCM.tempRec.Id = '+wCM.tempRec.Id);
            //set the contact to be emailed
            mess.setTargetObjectId(wCM.tempRec.ContactId__c);
            system.debug('wCM.tempRec.Id = '+wCM.tempRec.Id);
            id theRecId = wCM.tempRec.Id;
            system.debug('theRecId = '+ theRecId);            
            mess.setWhatId(theRecId);
            if (wCM.type_member == 'Participant') 
                mess.setTemplateId(temp.Id);
            else 
                mess.setTemplateId(volTemp.Id);                 
            messages.add(mess);            
        }
        messaging.sendEmail(messages);

Here is what I get from the debugger:
User-added image
It says the id is a284B0000007BOiQAM

but then the error I get says this 


System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, Invalid entity type for whatId.: [whatId, a284B0000007BPf]
Error is in expression '{!SendTheEmails}' in component <apex:commandButton> in page cmsendemailsvf: Class.CMSendEmails.SendTheEmails: line 129, column 1


Does anyone see what my problem is here?  I have no idea.