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 :
Small and medium business | Business Central, N...
Answered

Local BC Docker Container and Local VS ASP.NET Core API Endpoint Issue

(3) ShareShare
ReportReport
Posted on by 787
So I have BC 27.1 running in a local Docker container. And I have a Visual Studio 2022 ASP.NET Core web app also running. The issue involves a BC codeunit procedure that is making the API request. It returns back NavHttpClient Error Code 0. This is a simple GET request to the localhost that's running a debug of the ASP.NET Core web app. No authorization. No content body. When debugging on the VS Code end for the AL codeunit procedure, I can Ctrl+Click the request URL and it comes up just fine in a web browser. And using the same request URL in a Postman GET request, it comes back fine as well.
 
I'll paste my AL procedure code below. Along with another test procedure to a third-party test web service that works fine. It's just my own localhost web app that's failing. Perhaps this is due to server certificate validation failing? I tried disabling that feature in my code, although with BC 27.1, I thought that this couldn't be disabled. I even tried replacing the request URL with the http alternative to https and that runs into the same issue.
 
Any advice? I have enabled HttpClient calls in my extension setup. And the other test procedure works fine.
 
procedure MyApiCall(): Text // This fails.
    var
        Client: HttpClient;
        Request: HttpRequestMessage;
        Response: HttpResponseMessage;
        Content: HttpContent;
        Headers: HttpHeaders;
        ResponseText: Text;
        RequestUrl: Text;
    begin
        RequestUrl := 'https://localhost:7043/test';
        Request.SetRequestUri(RequestUrl);
        Request.Method('GET');
        Request.GetHeaders(Headers);
        Headers.Clear();
        Headers.Add('Accept', 'application/json');
        Headers.Add('Connection', 'keep-alive');
        Headers.Add('Accept-Encoding', 'gzip, deflate, br');
        Headers.Add('User-Agent', 'Business-Central-365');
        Client.UseServerCertificateValidation(false);
        Client.Send(Request, Response);
        Response.Content().ReadAs(ResponseText);
        exit(ResponseText);
    end;

procedure TestApiRequest(): Text // This works.
    var
        Client: HttpClient;
        RequestHeaders: HttpHeaders;
        RequestContent: HttpContent;
        ResponseMessage: HttpResponseMessage;
        RequestMessage: HttpRequestMessage;
        ResponseText: Text;
        RequestUrl: Text;
    begin
        RequestUrl := 'https://api.restful-api.dev/objects';
        RequestHeaders := Client.DefaultRequestHeaders();
        RequestContent.GetHeaders(RequestHeaders);

        Client.Get(RequestUrl, ResponseMessage);
        ResponseMessage.Content().ReadAs(ResponseText);
        exit(ResponseText);
    end;
I have the same question (0)
  • Greg Kujawa Profile Picture
    787 on at
    And I did take a look into how Visual Studio is handling server certificates when debugging. It by default creates the server certificate when first launched. I can verify this, since Ctrl+Clicking on the request URL that my BC codeunit procedure is using launches a web browser. Where the response works fine, and there is no server certificate warnings when hitting the https endpoint on localhost.
  • Verified answer
    OussamaSabbouh Profile Picture
    11,297 Super User 2026 Season 1 on at
    Hello,
     
    BC Docker can’t call https://localhost:7043, inside the container, localhost is the container itself.
    Your ASP.NET app is on the host, so you must call:
    https://host.docker.internal:7043/test

    Also ensure your ASP.NET Core app listens on 0.0.0.0, not only loopback.
    Network issue, not AL code.
     
    Regards,
    Oussama Sabbouh
  • Greg Kujawa Profile Picture
    787 on at
    Yes, that was the issue. Changing the API endpoint as you suggested, and opening up the web app to listen on any IP,  did the trick. Thanks for the point in the right direction!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,960 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,084 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,047 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans