I have AL code running fine on-prem, but when I deploy in BC running on Docker the request header seems to be created differently. The result is an error 415 "Unsupported Media Type"
This is parts of the AL code:
var
MyHttpClient: HttpClient;
RequestMessage: HttpRequestMessage;
ResponseMessage: HttpResponseMessage;
Headers: HttpHeaders;
Content: HttpContent;
XMLRequest: text;
XML_text: text;
begin
RequestMessage.SetRequestUri(URL);
RequestMessage.Method('POST');
Content.GetHeaders(Headers);
Headers.Remove('Content-Type');
Headers.Add('Content-Type', 'text/xml;charset=utf-8');
XmlDoc.WriteTo(XML_text);
Content.WriteFrom(XML_text);
RequestMessage.Content := Content;
MyHTTPClient.send(RequestMessage, ResponseMessage);
When running on-prem the Headers.Remove and Headers.Add needs to be there, otherwise I get error 415 also on-prem.
The same code seem to behave differently in BC. One problem I have is that I haven't figured out how to sniff the http-traffic from the Docker container. Normally I use Fiddler for that, but that's not possible here. Maybe if I succeeeded in configuring my host as a proxy for the container, but that doesn't seem trivial.
Is there any idieas on this out there?
Answers
This changes Content-Type from "text/plain; charset=utf-8" to "text/xml;charset=utf-8" when running locally in NAV2018 but not in BC
Reported here: https://github.com/Microsoft/AL/issues/3579
http://www.linkedin.com/in/larswestman