• Yogeshwar Tailor 17
  • NEWBIE
  • 0 Points
  • Member since 2017

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

Hi

 

We want to send an sms from Salesforce to Mobile through REST API

 

we used this code

 

Http http = new Http(); HttpRequest req = new HttpRequest();

req.setEndpoint('https://Account ID:Auth token@api.twilio.com/2010-04-01/Accounts');

req.setMethod('GET');

String username = 'xxxxxxxxxxxxxxxxxx';

String password = 'yyyyyyyyyyyyyyyyyyy';

Blob headerValue = Blob.valueOf(username + ':' + password);

String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);

req.setHeader('Authorization', authorizationHeader);

req.setBody('hai'); HTTPResponse res = http.send(req);

System.debug('STATUS:'+res.getStatus());

System.debug('STATUS_CODE:'+res.getStatusCode());

System.debug('----Responce----'+res.getBody());

 

 

but it gives status 401 notfound error how can we do Plz help me

 

how can we overcome this, Please post your reply at earliest.