function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramesh SomalagariRamesh Somalagari 

How to get SMS request via twilio

I have a class that can access the site url in the salesforce.
The site url "" and same as the twilio account sms URL but this class can't called.User-added image I have reference .The twilio SMS url correct are not how to check?The Twilio account SMS url and salesforce site url are same as of now.Whenever SMS is came via twilio then automatically Case is createin the sandbox.But here not happened.I doing correct producer are not?.Can someone please help me.How to resolve this problem.I have checked the twilio sms url like this "".which url I will give both Salesforce site url, Twilio SMS url.

    global class smsToApex
        Static TwilioAccount account = TwilioAPI.getDefaultAccount();        
        global static void incomingSMS()
            // This will error out with System.LimitException if we would exceed
            // our daily email limit
            String expectedSignature = RestContext.request.headers.get('X-Twilio-Signature');
            system.debug('ES' + expectedSignature);
            String url = 'https://' + RestContext.request.headers.get('Host') + '/services/apexrest' + RestContext.request.requestURI;
            Map <String, String> params = RestContext.request.params;
            // Validate signature
            if (!TwilioAPI.getDefaultClient().validateRequest(expectedSignature, url, params)) {
                RestContext.response.statusCode = 403;
                RestContext.response.responseBody = Blob.valueOf('Failure! Rcvd '+expectedSignature+'\nURL '+url/*+'\nHeaders'+RestContext.request.headers*/);
            RestContext.response.responseBody = Blob.valueOf('ok');       
            String caseFrom = params.get('From');
             String caseTo = params.get('To');
            String   caseBody = params.get('Body');         
              System.debug('Step 4 smsToApex caseFrom==>'+caseFrom);
              System.debug('Step 5 smsToApex caseTo===>'+caseTo);
              System.debug('Step 6 smsToApex caseBody===>'+caseBody);         
               Case ca = new Case();
                ca.Subject = 'Test smsToApex caseFrom'+caseFrom;
                ca.Description = 'Test smsToApex caseBody'+caseBody+','+caseTo;
                ca.Origin = 'Phone';
                INSERT ca;                 

In the Twilio log, can you see that your call of the APi were succeful ?
If the call is successful, you'll need to check Salesforce log.