You need to sign in to do that
Don't have an account?
raju p 4
System.CalloutException: Endpoint can not be null
i am getting this error >>
System.CalloutException: Endpoint can not be null
Error is in expression '{!sendsmsTwilio}' in component <apex:commandButton> in page sendsmstwilio: Class.sendsmsTwilio.sendsmsTwilio: line 28, column 1
Class.sendsmsTwilio.sendsmsTwilio: line 28, column 1
and its apex code is>>
public class sendsmsTwilio {
public string Messages{set;get;}
public string ACCOUNTSID{set;get;}
public string AUTHTOKEN{set;get;}
public string Mobile{set;get;}
public string result{set;get;}
public contact con;
public sendsmsTwilio(ApexPages.StandardController controller) {
con =(contact)controller.getrecord();
}
public void sendsmsTwilio(){
BoxIntrgration__c c= [SELECT accountsid__c, AUTHTOKEN__c from BoxIntrgration__c where name=:'twilio'];
ACCOUNTSID=c.accountSid__c;
AUTHTOKEN=c.AUTHTOKEN__c;
Http p= new http();
HttpRequest req= new HttpRequest();
string url='https://api.twilio.com/2010-04-01/Accounts/AC58cf47802fa54fe399e85fd822bf2103/Messages.json';
string body ='Well come';
body=body+'&To=+con.phone';
body=body+'&AUTHTOKEN';
body=body+'&MessagingServiceSid=MG3d0796691bb5c2d7ed266c1850240962';
req.setmethod('POST');
httpresponse res= new httpResponse();
res=p.send(req);
result=res.getbody();
}
}
here is i am trying to send sms from contact and its visualforce page
<apex:page standardController="contact" extensions="sendsmsTwilio">
<apex:form >
<apex:pageblock >
<apex:inputtext value="{!contact.phone}"/>
<apeX:pageblockButtons >
<apex:commandButton value="SendSms" action="{!sendsmsTwilio}"/>
</apeX:pageblockButtons>
</apex:pageblock>
</apex:form>
{!result}
</apex:page>
i tryed using try and catch but , but i am not geting message ,please do the needful
System.CalloutException: Endpoint can not be null
Error is in expression '{!sendsmsTwilio}' in component <apex:commandButton> in page sendsmstwilio: Class.sendsmsTwilio.sendsmsTwilio: line 28, column 1
Class.sendsmsTwilio.sendsmsTwilio: line 28, column 1
and its apex code is>>
public class sendsmsTwilio {
public string Messages{set;get;}
public string ACCOUNTSID{set;get;}
public string AUTHTOKEN{set;get;}
public string Mobile{set;get;}
public string result{set;get;}
public contact con;
public sendsmsTwilio(ApexPages.StandardController controller) {
con =(contact)controller.getrecord();
}
public void sendsmsTwilio(){
BoxIntrgration__c c= [SELECT accountsid__c, AUTHTOKEN__c from BoxIntrgration__c where name=:'twilio'];
ACCOUNTSID=c.accountSid__c;
AUTHTOKEN=c.AUTHTOKEN__c;
Http p= new http();
HttpRequest req= new HttpRequest();
string url='https://api.twilio.com/2010-04-01/Accounts/AC58cf47802fa54fe399e85fd822bf2103/Messages.json';
string body ='Well come';
body=body+'&To=+con.phone';
body=body+'&AUTHTOKEN';
body=body+'&MessagingServiceSid=MG3d0796691bb5c2d7ed266c1850240962';
req.setmethod('POST');
httpresponse res= new httpResponse();
res=p.send(req);
result=res.getbody();
}
}
public class sendsmsTwilio { public string Messages{set;get;} public string ACCOUNTSID{set;get;} public string AUTHTOKEN{set;get;} public string Mobile{set;get;} public string result{set;get;} public contact con; public sendsmsTwilio(ApexPages.StandardController controller) { con =(contact)controller.getrecord(); } public void sendsmsTwilio(){ BoxIntrgration__c c= [SELECT accountsid__c, AUTHTOKEN__c from BoxIntrgration__c where name=:'twilio']; ACCOUNTSID=c.accountSid__c; AUTHTOKEN=c.AUTHTOKEN__c; Http p= new http(); HttpRequest req= new HttpRequest(); string url='https://api.twilio.com/2010-04-01/Accounts/AC58cf47802fa54fe399e85fd822bf2103/Messages.json'; string body ='Well come'; body=body+'&To=+con.phone'; body=body+'&AUTHTOKEN'; body=body+'&MessagingServiceSid=MG3d0796691bb5c2d7ed266c1850240962'; req.setmethod('POST'); httpresponse res= new httpResponse(); res=p.send(req); result=res.getbody(); } }
here is i am trying to send sms from contact and its visualforce page
<apex:page standardController="contact" extensions="sendsmsTwilio">
<apex:form >
<apex:pageblock >
<apex:inputtext value="{!contact.phone}"/>
<apeX:pageblockButtons >
<apex:commandButton value="SendSms" action="{!sendsmsTwilio}"/>
</apeX:pageblockButtons>
</apex:pageblock>
</apex:form>
{!result}
</apex:page>
i tryed using try and catch but , but i am not geting message ,please do the needful
Please check below trailhead module for more information
1) https://trailhead.salesforce.com/en/modules/apex_integration_services/units/apex_integration_rest_callouts
Let ys know if this will help you