Exchange data with an external REST service
Sending a REST request creates two independent outcomes: the Business Central platform either completes the call or doesn’t, and the external service returns an HTTP status if it receives and processes the request. Evaluate the outcomes separately before you interpret the response body.
Allow outbound requests
Business Central blocks outbound HTTP calls from an extension by default. Before you test an integration, open Extension Management, select the extension, and then select Configure. On the Extension Settings page, turn on Allow HttpClient Requests.
This setting applies to each app, including a library app that performs the call on behalf of another extension. When an environment is copied, confirm the setting in the copied environment before you troubleshoot the AL code.
Business Central online also applies server-side request forgery protection. Requests to internal IP addresses are blocked. Use a publicly reachable HTTPS endpoint for an online environment. The platform validates the endpoint’s server certificate, so a certificate validation failure is a transport failure rather than an HTTP status from the service.
Separate transport and HTTP outcomes
Methods such as Get, Post, Put, Delete, and Send return a Boolean. Check that value before accessing HttpResponseMessage.Content. A false result can indicate an invalid URI, a DNS or network problem, a timeout, a certificate problem, a blocked outbound call, or a response that exceeds the allowed size.
A platform-blocked call can surface a runtime message before your own transport-error branch runs. Record the actual platform evidence; without a completed exchange, there isn't a service HTTP status to infer.
After a true result, check HttpResponseMessage.IsSuccessStatusCode. This method returns true for status codes from 200 through 299.
local procedure ReadPost(PostId: Integer) ResponseText: Text
var
Client: HttpClient;
Response: HttpResponseMessage;
Endpoint: Text;
begin
Endpoint := StrSubstNo('https://jsonplaceholder.typicode.com/posts/%1', PostId);
if not Client.Get(Endpoint, Response) then
Error('The platform could not complete the REST request.');
Response.Content().ReadAs(ResponseText);
if not Response.IsSuccessStatusCode() then
Error(
'The service returned status %1 (%2). Response: %3',
Response.HttpStatusCode(),
Response.ReasonPhrase(),
CopyStr(ResponseText, 1, 250));
end;
The sample reads the body after transport succeeds and before it reports an unsuccessful status. This order preserves a service-provided error payload. Limit what you show in a user-facing error, and don’t expose tokens or personal data. Store fuller diagnostic context through an approved telemetry or logging design.
The response excerpts in these examples are for the public service's synthetic test data. CopyStr bounds length; it doesn't redact secrets, personal data, or sensitive business values. In production, allowlist or redact diagnostic fields before displaying or retaining them, and follow the approved logging and retention policy.
Interpret common service outcomes
Status families help classify a response, but the service contract defines the exact action.
| Status family | Meaning | Typical integration action |
|---|---|---|
| 2xx | The service accepted the request. | Validate and process the response body. |
| 3xx | The resource requires redirection. | Confirm whether the client and contract permit redirection. |
| 4xx | The request or caller doesn’t satisfy the contract. | Correct the method, URI, headers, authentication, or body. |
| 5xx | The service encountered an error while processing the request; this status alone doesn't prove that the request was valid. | Preserve diagnostics and apply the service’s retry guidance. |
Examples include status 400 for an invalid request, 401 for missing or invalid authentication, 404 for a resource that doesn’t exist, 405 for an unsupported method, 415 for an unsupported content type, and 429 for throttling. Status 503 commonly indicates a service that is unavailable or overloaded.
Don’t retry every failure. A repeated 400 response doesn’t become valid without changing the request. For transient statuses such as 429 or 503, use bounded retry logic, respect a Retry-After header when the service supplies it, and avoid holding an interactive session in a long retry loop.
Account for runtime behavior and limits
An outbound HttpClient call blocks AL execution for the session until the call completes. Keep synchronous calls short, set an appropriate timeout, and avoid placing a slow remote dependency inside a transaction that holds database locks.
Business Central online limits an HttpClient response to 150 MiB. A response beyond that limit causes the call to return false. Pagination and narrower queries are preferable to transferring a large result and filtering it after download.
Design diagnostic messages to answer the following questions:
Which operation and endpoint failed?
Did the platform complete the call?
Which HTTP status and reason phrase did the service return?
Which safe portion of the response body explains the failure?
Which correlation value connects the failure to service-side logs?
This evidence separates configuration problems from request defects and service outages. For current platform behavior and status-code guidance, see Call external services with the HttpClient data type.