web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Consume External API on Business central

(7) ShareShare
ReportReport
Posted on by 34

Hello, I want consume a External API to auto complete  customer address on Business Central , I would like to know what is the best option to do this . APi is https://getaddress.io/Documentation .

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

  • CU20021523-0 Profile Picture
    16 on at
    A very old thread, but did you end up getting it working?
     
    I have been testing multiple endpoint URLs and haven't gotten it to work yet. The default "https://api.getAddress.io/find/" endpoint with the API key entered does not seem to return any results when using valid postcodes.
     
    Cheers
  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at
    Hi,
     
     
    This playlist is not complete but example that you are looking for is ready.
     
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,268 Super User 2025 Season 2 on at
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    Yes you can use the most effective way to integrate this in Business Central is by using AL code to consume the API and pairing it with a custom page control (via a page extension) to trigger the lookup.
     
    See the following example if help:
    codeunit 50100 "GetAddressIntegration"
    {
        procedure GetAddressFromPostcode(Postcode: Text; var Customer: Record Customer)
        var
            HttpClient: HttpClient;
            HttpResponse: HttpResponseMessage;
            ResponseText: Text;
            JsonObj: JsonObject;
            JsonToken: JsonToken;
            AddressesArray: JsonArray;
            Url: Text;
            ApiKey: Text;
        begin
            ApiKey := 'YOUR_API_KEY'; // Store securely in a setup table or key vault
            Url := 'https://api.getAddress.io/find/' + Postcode + '?api-key=' + ApiKey;
    
            if not HttpClient.Get(Url, HttpResponse) then
                Error('Failed to connect to getAddress.io API.');
    
            if not HttpResponse.IsSuccessStatusCode then
                Error('API Error: %1', HttpResponse.HttpStatusCode);
    
            HttpResponse.Content.ReadAs(ResponseText);
            JsonObj.ReadFrom(ResponseText);
    
            // Extract first address for simplicity (you could add a selection UI)
            if JsonObj.Get('addresses', JsonToken) then begin
                AddressesArray := JsonToken.AsArray();
                if AddressesArray.Get(0, JsonToken) then begin
                    SplitAddress(JsonToken.AsValue().AsText(), Customer);
                end;
            end else
                Message('No addresses found for postcode %1.', Postcode);
        end;
    
        local procedure SplitAddress(AddressText: Text; var Customer: Record Customer)
        var
            Parts: List of [Text];
        begin
            // Address comes as a single string, e.g., "10 Downing Street, London, SW1A 2AA"
            Parts := AddressText.Split(', ');
            if Parts.Count >= 1 then Customer.Address := CopyStr(Parts.Get(1), 1, MaxStrLen(Customer.Address));
            if Parts.Count >= 2 then Customer.City := CopyStr(Parts.Get(2), 1, MaxStrLen(Customer.City));
            if Parts.Count >= 3 then Customer."Post Code" := CopyStr(Parts.Get(3), 1, MaxStrLen(Customer."Post Code"));
            // County isn’t always explicit; you could extend logic or use API’s formatted_address
        end;
    }
     
  • Suggested answer
    D Curd Profile Picture
    71 on at
    If anyone is still struggling with this, it looks like the https://api.getaddress.io/find/ URL has been retired and replaced with https://api.getaddress.io/autocomplete/. The old URL is still referenced on line22 in the upgrade codeunit of the standard Postcode lookup app here ALAppExtensions/Apps/GB/UKPostcodeGetAddressIO/app/src/PostcodeGetAddressioUpgrade.Codeunit.al at main · microsoft/ALAppExtensions, which I think is part of problem.  If you uninstall the app and select the delete data option, and then re-install it it will re-populate the config table using the new URL.
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    8,760 on at

    Hi

    Yes, you can consume external APIs like getAddress.io in BC to auto-complete customer addresses.

    The most effective approach is to use AL code with HttpClient and pair it with a custom page extension to trigger the lookup.

     

    Implementation Notes:

    • You can trigger this logic from a custom action on the Customer Card or via a FactBox.
    • Consider adding a lookup dialog if multiple addresses are returned.
    • Store the API key securely and avoid hardcoding it.


    Here’s a screenshot showing how to structure the HttpClient call and parse the JSON response:

    Helpful References:
    How to Connect to External APIs – Business Central Geek
    GitHub – API Consumption Examples
    REST API Web Services – Microsoft Learn

    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

  • Suggested answer
    YUN ZHU Profile Picture
    95,327 Super User 2025 Season 2 on at
    Hi, hope the following can give you some hints.
    Dynamics 365 Business Central: Generate barcode through external services/APIs (Telepen, Swiss QR Code, QR codes with colors, images or text……)
    Dynamics 365 Business Central: Where is cloud(SaaS) data actually stored (Get BC public IP address, City, Region, Country, Location etc.)
    Dynamics 365 Business Central Blog Series: REST API web services (APIs)
     
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,329

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,250 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,365 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans