Network Error on Internet Explorer 11 when POSTing XML with CORS

1

I'm trying to send a POST request to an API which requires XML in the request body and responses with XML data. The API is on another domain, so CORS has to be used. IE11 sends a successful CORS preflight. Here is a simplified test case which fails with the following error on Internet Explorer 11 on Windows 7:

SCRIPT7002: XMLHttpRequest: Network Error 0x800c0007, No data is available for the requested resource.

    var body = '<?xml version="1.0" encoding="UTF-8"?> '
    + '<Trias version="1.1" xmlns="http://www.vdv.de/trias" xmlns:siri="http://www.siri.org.uk/siri" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> '
    + '    <ServiceRequest> '
    + '        <siri:RequestTimestamp>2016-06-27T13:34:00</siri:RequestTimestamp> '
    + '        <siri:RequestorRef>EPSa</siri:RequestorRef> '
    + '        <RequestPayload> '
    + '            <StopEventRequest> '
    + '                <Location> '
    + '                    <LocationRef> '
    + '                        <StopPointRef>8502113</StopPointRef> '
    + '                    </LocationRef> '
    + '                    <DepArrTime>2017-01-03T10:22:00</DepArrTime>'
    + '                </Location> '
    + '                <Params> '
    + '                    <NumberOfResults>1</NumberOfResults> '
    + '                    <StopEventType>departure</StopEventType> '
    + '                    <IncludePreviousCalls>true</IncludePreviousCalls> '
    + '                    <IncludeOnwardCalls>true</IncludeOnwardCalls> '
    + '                    <IncludeRealtimeData>true</IncludeRealtimeData> '
    + '                </Params> '
    + '            </StopEventRequest> '
    + '        </RequestPayload> '
    + '    </ServiceRequest> '
    + '</Trias> ';

    $(document).ready(function() {
      $('button').click(function() {
        $.ajax('https://odpch-api.begasoft.ch/trias-stackoverflow', {
          method: 'POST',
          headers: {
            'Content-Type': 'text/xml',
            'Authorization': '57c5dadd5e6307000100005e4365c41fa4d946a44ecbd19508fbef64'
          },
          data: body,
          dataType: 'text'
        }).done(function(data) {
          $('#response').text(data);
        });
      });
    });
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
<button>Ajax</button>
<div id="response"></div>
</body>
</html>

Edit: Running it from the snippet give another error, here is the pastebin with a complete example: http://pastebin.com/yTL7mrYF

The preflight request and the post request itself is visible in the dev tools. For the POST request, only the response header is visible, but the response body says "No data to view".

I see in Fiddler that the response gets sent back from the server, but somehow Internet Explorer can not display it.

The service is behind Tyk, an API management software.

Obviously this works in Firefox and Chrome.

ajax
xml
internet-explorer
cors
tyk
asked on Stack Overflow Jan 13, 2017 by fotcorn • edited Jan 13, 2017 by fotcorn

1 Answer

3

The problem is the compressed response (deflate). When I remove the Accept-Encoding request header, the response is not compressed and it works in Internet Explorer.

answered on Stack Overflow Jan 16, 2017 by fotcorn

User contributions licensed under CC BY-SA 3.0