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
My Salesforce 20My Salesforce 20 

Resi api

HTTP Rest post request to send data from salesforce to end point url (this end point url is other than Salesforce).
Can anyone please give a sample end point URL to test and Source code related to it?
Am a newbie to salesforce,Can anyone explain.

 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

https://github.com/SalesforceSFDC/Apex-Integration-Services

http://cyukt.com/learn/salesforce-rest-api-callout-consume-external-rest-api/

https://www.mstsolutions.com/technical/apex-callouts-to-display-external-data-in-salesforce/

https://www.accusoft.com/blog/communicating-with-external-systems-in-a-salesforce-app/

https://andyinthecloud.com/2017/07/23/simplified-api-integrations-with-external-services/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi,

Try the following code in which endpoint relates to twilio:
 
public class HttpCalloutSample {

  // Pass in the endpoint to be used using the string url
  @AuraEnabled
  public static String getCalloutResponseContents1(String phoneNumber) {

    // Instantiate a new http object
    Http h = new Http();

    
    String instBody = 'Url=http://demo.twilio.com/docs/classic.mp3&To='+phoneNumber+'&From=+phoneNumber';
    String inEndPoint = 'https://api.twilio.com/2010-04-01/Accounts/ACfae022703791c240df9da8a2c1d21ab8/Calls.json';

    String uname = 'username';
    String pswd = 'password';

    String new1 = uname+':'+pswd;
    Blob mediate = Blob.valueOf(new1);
    String credential = 'BASIC ' +EncodingUtil.base64Encode(mediate);
    System.debug('Credential-->'+credential);

    HttpRequest req = new HttpRequest();
    req.setEndpoint(inEndPoint);
    req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
    req.setMethod('POST');
    req.setBody(instBody);
    req.setHeader('Authorization', credential);


    // Send the request, and return a response
    HttpResponse res = h.send(req);
    System.debug('Response-->'+res.getBody());
    return res.getBody();
  }
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com