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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

What is the process for making web service calls to external REST web services from Business Central?

(0) ShareShare
ReportReport
Posted on by

What is the process for making Web Service calls to external REST web services from Business Central?

I'm a web developer looking to set up 2 way communication between an existing web application I am working on and MS Dynamics Business Central.

I am already able to make web service calls from an external web app into Business Central via it's api's and that process is reasonably well documented.

What doesn't seem to have any documentation though is the process of outbound communication from Business Central to a web app via web service calls, webhooks, callbacks, something else???

Unfortunately i'm finding it difficult to search for the answer to my question due to most results coming back for NAV or other vastly out of date or strictly  on-premises products.

The detailed requirement is to allow a Business Central user prepare a Payment Journal to pay a vendor invoice(s) and upon a User Action in Business Central allow the Payment Journal details to be sent to our web service for processing. The external web app can then use the Business Central API's to perform the required activities.

Based upon what is ultimately possible, the user action could be a simple "transmit to processing service" menu item or it could trigger off an acceptance work flow. Unfortunately I'm struggling to find documentation to enable either approach.

Any guidance would be much appreciated.

Categories:
  • Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    If you want to performa a web service call from AL, you need to use the HttpClient object:

    docs.microsoft.com/.../httpclient-data-type

    Obviously, every external WS has its own specifications...

  • Community Member Profile Picture
    on at

    Thanks for the link. After posting my question yeaterday I went and set up VSCode for AL and played with the hello world in the sandbox as part of my investigation.

    Just to be clear though and truly narrow down the investigation and to help others in the same situation...

    is the only way to do it within an addon written in AL?

  • Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    This is the standard way to start an HTTP outbound call from AL. You’re not strictly forced to do all in AL, you can for example call an Azure Function that in turns calls your external WS (if you can’t do all in AL for any reason) or using other integration techniques.

  • Community Member Profile Picture
    on at

    A quick search along those lines turns up [View:https://community.dynamics.com/nav/b/navmusings/archive/2018/12/26/invoking-azure-functions-to-replace-dot-net-calls-in-c-al-or-al:750:50]

    Which seems pretty straight forward except for the critically important part relevent to my question which is largely skipped over namely...

    Therefore, to replace a set of dotnet calls we need a worker placed somewhere else other than in AL or C/AL and a caller of that worker services placed in the extension. In my example use a codeunit (caller) in the extension range with a subscriber event defined that calls an Azure function(worker).

    Reading that implies that a worker Extention (presumably) written in AL is still needed to call the Azure function and that the Azure Function cannot actually be configured to be called directly from Business Central.

    My entire question though relates to obtaining that precise clarification because assumptions are just expensive pending mistakes. It would be unfortunate if I spent time puting together the Azure function and still couldn't call it.

  • Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    You can absolutely call an Azure Function via AL code. Just declare an HttpClient variable, an HttpRequest variable and use something like:

    HttpClient.Get(yourfunctionurl,response);

    response.Content.ReadAs(...);

    I can post a working sample (not at my pc now), for the moment you can read here:

    vjeko.com/invoking-azure-functions-al

  • Community Member Profile Picture
    on at

    I was 1000000% percent sure that I can call an Azure function from AL code from your previous post.

    Is AL the only way to do it though? Yes / No

    Think of it a different way...

    I need to get from Los Angeles to San Francisco.

    I can do that by Car (AL extention) but the car can be a SUV (utilises an azure Function) or a Sports Coupe(direct from AL) .

    I'm asking if a car is the only way? Yes/No. Not what type of car.

    For example for the real world journey between those cities you could use a plane, train, boat and you could even walk or ride a bicycle if you wanted.

    So other than an extention written in AL using VS Code environment what other mechaisms are there?

    I'm asking because i'm sensibly trying to avoid adding another (potentially unnecessary) layer to my technology stack.

  • Community Member Profile Picture
    on at

    Digging deeper there is an ability to recieve webhook calls for records that you can subscribe to. Not really useful in any conceivable context given the 3 day lifetime but still an alternative.

    https://docs.microsoft.com/en-au/dynamics-nav/fin-graph/dynamics_subscriptions

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans