Content-Type in SOAP request. Different behaviour On-prem vs. BC

Lars_WestmanLars_Westman Member Posts: 116
edited 2018-09-05 in NAV Three Tier
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:
    MyHttpClient: HttpClient;
    RequestMessage: HttpRequestMessage;
    ResponseMessage: HttpResponseMessage;
    Headers: HttpHeaders;
    Content: HttpContent;
    XMLRequest: text;
    XML_text: text;
    Headers.Add('Content-Type', 'text/xml;charset=utf-8');
    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?


  • Lars_WestmanLars_Westman Member Posts: 116
    edited 2018-09-05
    I was able to inspect the traffic and it looks like Headers.Remove and Headers.Add doesn't work the same way in the two environments.

    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
    Headers.Add('Content-Type', 'text/xml;charset=utf-8');

    Reported here:
Sign In or Register to comment.