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

Call an externel WebService

(3) ShareShare
ReportReport
Posted on by 18

Hello,

I'm working on a Business Central SaaS environment and I'm trying to consume an external web service using the HttpClient data type in AL. However, I'm encountering the following error when executing the HTTP request:

"An error occurred while executing the HTTP request. Make sure you are connecting to a valid endpoint."

 

I've confirmed that the endpoint URL is correct and accessible via browser/Postman, Is there any additional configuration required in BC SaaS for HttpClient calls? Could this be related to certificate validation, or https requested?

Thanks in advance for your help!

Capture d'écran 2025-05-15 125129.png
I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,150 Super User 2025 Season 2 on at

    This error can sometimes occur even if the endpoint works in a browser or Postman. A few things to double-check:

    ✅ Handle all headers and authentication properly. If the service requires API keys or other custom headers, make sure they're correctly set in your HttpRequestMessage. Missing or incorrect headers can cause silent failures.

     

    ✅ Log the full response content for more insight. Even if the call fails, check HttpResponseMessage.IsSuccessStatusCode() and read the content using Response.Content.ReadAsString() to see if the service is returning a more detailed error message.

    If you're still having trouble, feel free to share a snippet of your AL code and the request/response details (with sensitive info removed), and I’ll be happy to help you debug it further.

     

    procedure CallExternalService()
    var
        Client: HttpClient;
        Request: HttpRequestMessage;
        Response: HttpResponseMessage;
        Content: Text;
    begin
        // Prepare the request
        Request.SetRequestUri('https://api.example.com/data');
        Request.Method := 'GET';
    
        // Add custom headers (e.g., API key)
        Request.GetHeaders().Add('Authorization', 'Bearer YOUR_API_KEY_HERE');
        Request.GetHeaders().Add('Accept', 'application/json');
    
        // Send the request
        if Client.Send(Request, Response) then begin
            // Check if the response was successful
            if Response.IsSuccessStatusCode() then begin
                Response.Content().ReadAs(Content);
                Message('Success: %1', Content);
            end else begin
                Response.Content().ReadAs(Content);
                Message('Failed. Status: %1 - %2', Response.HttpStatusCode(),
    end;
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at
    This issue typically occurs when the endpoint URL is incorrect or incomplete. However, since you're able to trigger the request successfully in Postman, we can rule that out. Another possible cause could be the authentication token being generated on the Business Central side — try validating that.
     
     
  • Ilyes Ben Jaoued Profile Picture
    18 on at
    The issue involves a simple POST request that requires a JSON payload in the body. You can see the screenshot below.
     
     
     
  • Suggested answer
    KP - Solution Architect Technical Profile Picture
    658 on at
     
    Can you check the authorization method in the AL code.
     
     
     
    Thanks,
    KP
  • Rick Folkner Profile Picture
    21 on at
    I'm getting the same error this morning, was working fine yesterday.  Seemed to happen after BC updated to v26 last night.  Did Microsoft change something in the http client in 26?
  • Rick Folkner Profile Picture
    21 on at
    I figured out my issue with this.  in BC26 they added a feature that forces certificate validation on htttpclient calls.  My issue was the certificate on the API Server had an issue so it wasn't validating. 
     
    Here is a link to the Microsoft documentation. 
     
     
    Thanks,
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,603 Super User 2025 Season 2 on at

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 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans