Business Central - check internet connection

Hi,
Is there any way to check if the Business Central OnPrem has access to the internet? Some method like IsNetworkAvailable():Boolean ?

Answers

  • SanderDkSanderDk Member Posts: 497
    You could do at HTTP GET on a public site like https://google.dk,
    if you get a 200 OK then you are able to connect to other sites.
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
  • GabrielMuzolfGabrielMuzolf Member Posts: 4
    That was my idea as well to ping some public domain, but I was wondering if there is a better sollution, like a system codeunit with this kind of functionality.
    Won't it work incorrectly if http request is blocked for our extension?
    umvve572q6zd.png

  • SanderDkSanderDk Member Posts: 497
    edited 2022-08-04
    Yes it will, but you could add a few lines of code to check that with the HTTPResponseMesage.IsBlockedByEnvironment()
    trigger OnRun()
        var
            Client : HttpClient;
            Response : HttpResponseMessage;
        begin
            if Response.IsBlockedByEnvironment() then
                Error('Please give access on extension management');
        end;
    
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
Sign In or Register to comment.