Unauthorized endpoint, please check Setup->Security->Remote site settings endpoint

余生颓废 提交于 2019-12-08 08:14:35

问题


I'm unable to send an SMS via Twilio API. I got the exception below:

ERROR : Unauthorized endpoint, please check Setup->Security->Remote site settings endpoint: url

global class SampleSMSTest {
    @future(callout=true)
    public static void testsms() {
        try {
            String account = 'xxxxxxxxx';
            String token = 'xxxxxxxxxx';
            TwilioRestClient client = new TwilioRestClient(account, token);
            Map<String, String> params = new Map<String, String> {
                'To' => '+91953835xxxx',
                'From' => '+1920569xxxx', // twilio registered number
                'Body' => 'Hello there!'
            };
            TwilioMessage message = client.getAccount().getMessages().create(params);
        } catch (Exception e) {
            System.debug('Main error==========>' + e);
        }
    }
}

回答1:


This looks like Salesforce APEX code. Anytime you want to call an external URL from Salesforce, you need to set the URL as a safe remote site. The error message tells you exactly where to go in SF. Add the Twilio URL "api.twilio.com" to the list.




回答2:


Add the Twilio URL in sandbox as following path

Administration Setup  > Security Controls > Remote Site Settings > click "**New Remote Site**" button.

I have re-solved my problem



来源:https://stackoverflow.com/questions/24290617/unauthorized-endpoint-please-check-setup-security-remote-site-settings-endpoi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!