web
You’re offline. This is a read only version of the page.
close
Skip to main content
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!

I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,089 Super User 2025 Season 2 on at
    Call an externel WebService

    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
    92,831 Super User 2025 Season 2 on at
  • Suggested answer
    RockwithNav Profile Picture
    8,370 Super User 2025 Season 2 on at
    Call an externel WebService
    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
    Call an externel WebService
    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
    652 on at
    Call an externel WebService
     
    Can you check the authorization method in the AL code.
     
     
     
    Thanks,
    KP
  • Rick Folkner Profile Picture
    21 on at
    Call an externel WebService
    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
    Call an externel WebService
    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
    19,160 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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,275

#2
Sumit Singh Profile Picture

Sumit Singh 2,677

#3
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,526

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans