This is a common behavior with NTLM authentication — it requires a multi-step handshake (3 requests):
1. Initial request without credentials (to get 401 Unauthorized with NTLM challenge).
2. Second request with NTLM negotiation token.
3. Third request with actual authentication info — this one succeeds.
Postman handles this automatically, but in AL HttpClient you must manually implement this handshake or use simpler auth.
Suggestions for your AL code in Business Central 14:
Basic Authentication with HttpClient can be tricky with NTLM-enabled services; BC14's AL HttpClient does not support automatic NTLM handshake.
If your service requires NTLM, try:
Use Windows Credential Manager or run the code on a machine where the user context has access.
Or call the SOAP service externally (e.g., Azure Function, .NET service) that handles NTLM, then call your function from AL.
Alternatively, if possible, disable NTLM and enable Basic Authentication only on the SOAP service in Business Central service settings (and in IIS config).
To set Basic Auth header manually in AL:
var
HttpClient: HttpClient;
RequestMessage: HttpRequestMessage;
ResponseMessage: HttpResponseMessage;
AuthValue: Text;
begin
AuthValue := 'Basic ' + Base64Encode('username:password');
RequestMessage := HttpRequestMessage.Create('POST', URL);
RequestMessage.Headers.Add('Authorization', AuthValue);
// add SOAP body etc.
HttpClient.Send(RequestMessage, ResponseMessage);
end;
For NTLM, AL HttpClient in BC14 does not have built-in support; you might need a proxy or external service as a workaround.
Mark below checkbox to make this answer Verified if it helps you. ✅