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."
HttpClient
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!
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.
HttpRequestMessage
✅ 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.
HttpResponseMessage.IsSuccessStatusCode()
Response.Content.ReadAsString()
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;
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 4,275
Sumit Singh 2,677
Nimsara Jayathilaka. 2,526