If you want to see a practical walkthrough for testing outbound API calls please navigate to my latest video:
The video focuses on recent innovations in Dynamics 365 Business Central 2025 Wave 1, where Microsoft has introduced enhanced mechanisms for mocking outbound HTTP requests—a common challenge for apps that integrate with external APIs. I’ll be presenting the new Test Runner app, demonstrating how developers can leverage test codeunits together with the TestHttpRequestPolicy property to gain fine-grained control over outbound HTTP client calls during testing.
Mock outbound HttpClient web service calls during testing – Business Central | Microsoft Learn
The new TestHttpRequestPolicy property for codeunits has three modes—Block outbound requests, Allow outbound from handler, and Allow outbound requests—offering flexible testing options for different scenarios. My video illustrates each mode using sample codeunits, showing how to simulate, permit, or block outbound API interactions according to the policy set, making it easier to safeguard against unintended side effects and control costs, especially when working with paid APIs like Azure OpenAI services.
The demos I created are using a free weather API as a stand-in for real-world external services. I go over the setup—acquiring an API key and making test calls—I also go over setting up policy values, running tests in Visual Studio Code, and reviewing results in the Microsoft’s AL Test Tool extension.
I go over some limitations: although the “Allow outbound from handler” mode is designed to let users intercept and mock HTTP requests before they exit Business Central, it requires custom handler functions that, at the time of recording, cannot be used in cloud extensions due to scope restrictions. Of course, the limitation disappears if you write and test your AL test codeunits against a BC container or an on-prem installation.