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

API Calls to external servers from salesforce

Hi gurus,

We have a requirement to make API calls for ABN lookup.
Requirement is we get the "ABN" from our clients and we need to fetch their Business name from the ABN register (this is being done manually at the moment and we are thinking to automate this process). I am not sure where to start. can any one guide me in right way?
Cloud AtlasCloud Atlas
Your team can write a RESTful service to make a api callout to ABN register to fetch the Business Name based on a SOQL query of  "ABN: value in Salesforce.
For this you will need to talk to ABN register and ask them to expose a URL ( api endpoint) to callout to ...
Since I don't know the system, I cannot describe more...
Here is some sample info that might be helpful which I pulled from development guides... 

I sincerely hope it helps you.

You can set all your header and authenticaltion informaiton using the built in HttpRequest library (, and then make your call out with http.send(req);

Which returns your HTTPResponse object, that you can then parse. Read
for more information on that.

HTTP (RESTful) Services
Apex supports HTTP Services with several built in Apex classes to creating HTTP requests like GET, POST, PUT, and DELETE. There are 3 main classes:
HTTP Class: Use this class to initiate an HTTP request and response.
HttpRequest Class: Use this class to programmatically create HTTP requests.
HttpResponse Class: Use this class to handle the HTTP response returned by the HTTP.Send() operation.
Together, these classes support the ability to develop HTTP request/response functionality within Apex. Using these HTTP classes supports the ability to integrate to REST-based services. It also enables the ability to integrate to SOAP-based web services as an alternate option to leveraging WSDL2Apex. By using the HTTP classes, instead of WSDL2Apex, the developer has more responsibility to handling the construction of the SOAP message both for the request and the response.
The following sections will show a few examples of how to use these classes to make a REST-based web service call. Check out projects on Code Share for more code - for example the Toolkit for Google Data APIs makes extensive use of these types of callouts.
HTTP Code Sample
Here is a simple example of using the HTTP, HTTPRequest, and HTTPResponse classes to construct a REST-based PUT message and receive the response. The example is making a REST-based web service call to the Amazon S3 service.
HttpRequest req = new HttpRequest(); 
  //Set HTTPRequest Method

  //Set HTTPRequest header properties
  req.setHeader('content-type', 'image/gif');
  req.setEndpoint( this.serviceEndPoint + this.bucket +'/' + this.key);

  //Set the HTTPRequest body	

  Http http = new Http();
   try {
        //Execute web service call here		
        HTTPResponse res = http.send(req);	

        //Helpful debug messages
} catch(System.CalloutException e) {
	//Exception handling goes here....

This example illustrates the setting of all required HTTP Headers, setting the body of the HTTPRequest object to the contents of the REST-based message, and checks the HTTPResponse status to make sure it was successfully processed.
Additional Considerations
Callout timeout is configurable in Apex Code (up to a maximum setting for a single callout):
The following is an example of setting a custom timeout for Web services callouts generated by WSDL2Apex:
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds

The following is an example of setting a custom timeout for HTTP callouts using the Apex HTTPRequest object:
HttpRequest req = new HttpRequest();
req.setTimeout(2000); // timeout in milliseconds

There is a maximum cumulative timeout for callouts by a single Apex transaction (currently 120 seconds - see the Apex Language Reference Guide for a definitive number). This time is additive across all callouts invoked by the Apex transaction.
The Apex callout request size must be smaller than a set maximum limit.
A governor limit is set on the number of web service calls or callouts per trigger or Apex class invocation.
See the Apex Language Reference Guide for definitive numbers of these limits.
Than You so much. I will start going through those documentation. Will get back to you with any questions.