
For our AL add-ons, we use some external services with REST endpoints. The requests are executed natively via Microsoft’s implementation of the HttpClient type.
For some requests, we receive an HTTP status 400 “Bad Request”.
In one case, the request even worked as an interactive process, but the same request returned “Bad Request” when executed via a job queue entry.
After some research, it became clear that the cause is the sometimes very long "correlation-context" header, which—when sending via HttpClient—appears to be injected by Microsoft before the request is sent.
It contains information about the context of the call, including the client, the object, parameters related to job queue entries, IDs, etc. Therefore, its length can vary. In a SaaS environment, it's even longer.
Some of the REST endpoints seem to have a length limit for HTTP headers. For example, if a header is longer than 300 characters, a “Bad Request” is returned. If the header is shorter, the request goes through.
We were able to reproduce this using Postman.
And now the actual question:
Is it possible to prevent this automatic injection of the "correlation-context" header? Or is there a publisher/hook that allows removing the header again before sending?